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,289,553 | 4,289,554 | calculate cosine similarity using java program | <p>i have a problem to calculate a similarity measurement to develop search engine for my final project...i have to use tf idf + cosine similarity in java and i don't have any idea how to calculate it. for your information i have my own database which is have 811 document</p>
| java | [1] |
2,258,778 | 2,258,779 | Why am I getting "parameter is not valid" exception on this code? | <pre><code>private void button8_Click(object sender, EventArgs e)
{
List<long> averages;
long res = 0;
_fi = new DirectoryInfo(subDirectoryName).GetFiles("*.bmp");
averages = new List<long>(_fi.Length);
for (int i = 0; i < _fi.Length; i++)
{
Bitmap myBitmaps = new Bitmap(_fi[i].Name);
//long[] tt = list_of_histograms[i];
long[] HistogramValues = GetHistogram(myBitmaps);
res = GetTopLumAmount(HistogramValues,1000);
averages.Add(res);
}
}
</code></pre>
<p>The exception is on the line: </p>
<pre><code>Bitmap myBitmaps = new Bitmap(_fi[i].Name);
</code></pre>
| c# | [0] |
5,645,406 | 5,645,407 | Errors checking and opening a URL using PHP | <p>Here is one script with out any errors</p>
<pre><code>$url="http://yahoo.com";
$file1 = fopen($url, "r");
$content = file_get_contents($url);
$t_beg = explode('<title>',$content);
$t_end = explode('</title>',$t_beg[1]);
echo $t_end[0];
</code></pre>
<p>And here is the same script using a look to check multiple urls and getting errors</p>
<pre><code> for ($j=1;$j<=$i;$j++) {
if ($x[$j]!=''){
$t_u = "http:".$x[$j];
$file2 = fopen($t_u, "r");
$content2 = file_get_contents($t_u);
$t_beg = explode('<title>',$content);
$t_end = explode('</title>',$t_beg[1]);
echo $t_end[0];
}
}
</code></pre>
<p>The error is <strong>Warning: fopen() [function.fopen]: php_network_getaddresses: getaddrinfo failed: No such host is known. in g:/</strong> </p>
<p>What exactly is wrong here?</p>
| php | [2] |
4,690,478 | 4,690,479 | How to resolve main class not found exception while creating jar? | <p>I am creating an executable jar file of a java project.
I successfully created a sample jar file with Hello world class.
I used following commands to create a jar:</p>
<pre><code> trail> javac -classpath "c:\Program Files\Java\jdk1.6.0_01\bin;" MyClass.java
bin> jar cvfm MyJar.jar manifest.mf trail\*.class
</code></pre>
<p>The Contents of my manifest.mf are</p>
<pre><code> Manifest-Version: 1.0
Created-By: 1.5.0_03 (Sun Microsystems Inc.)
Main-Class: trial.MyClass
</code></pre>
<p>This works fine.</p>
<p>Now when I use same procedure to create the jar of my project,
I am getting mainClass not found error.</p>
<pre><code>EDIT
My project need 2 third party jar.
So I have compiled My project by adding this jars in classpath.
I guess the problem is related with this jar file dependencies.
Can anybody help me to solve this problem?
</code></pre>
| java | [1] |
242,272 | 242,273 | Skipping function parameters | <p>If I have a function defined like this:</p>
<pre><code>function x($a, $b, $c)
</code></pre>
<p>How can I make a call like <code>query('a', 'b')</code>, with b replaced by $c?</p>
| php | [2] |
3,613,585 | 3,613,586 | Addressing first/last item in an ul, li | <p>How do you check whether a DOM element being clicked is either the 'first' li element or the 'last' li element in an unordered list item??</p>
| jquery | [5] |
2,414,222 | 2,414,223 | How can i zoom out Timeline Panel in eclipse SDK? | <p>How can i zoom out Timeline Panel when viewing trace file in eclipse SDK.</p>
<p>Thanks in advance.</p>
| android | [4] |
1,234,419 | 1,234,420 | Help with Sessions Issues | <p>This just a same script in different server:</p>
<p>The link below works. When you enter the correct characters it display success.</p>
<p><a href="http://mibsolutionsllc.com/captcha%5Ftest/test.php" rel="nofollow">http://mibsolutionsllc.com/captcha%5Ftest/test.php</a></p>
<p>This link below works. Even you enter the correct characters. Display always error. The session value doesn't give function the right way.</p>
<p><a href="http://www.universitywomenshealthcare.com/uwh-content/captcha%5Ftest/test.php" rel="nofollow">http://www.universitywomenshealthcare.com/uwh-content/captcha%5Ftest/test.php</a></p>
<p>If it's a sessions issue, how would one go about fixing this?</p>
| php | [2] |
3,633,875 | 3,633,876 | Android - for loop: for (boolean bool = true; ; bool = false) | <p>The following snippet is part of a Human Step Detection Android App
downloaded from the Play Store. Since it works fine, so I assume the
codes all make sense.</p>
<pre><code>private boolean isMotion(float[] paramArrayOfFloat)
{
if ((Math.abs(this.mOldAcc[0] - paramArrayOfFloat[0]) > 1.0F) || (Math.abs(this.mOldAcc[1] - paramArrayOfFloat[1]) > 1.0F) ||
(Math.abs(this.mOldAcc[2] - paramArrayOfFloat[2]) > 1.0F));
for (boolean bool = true; ; bool = false)
{
this.mOldAcc[0] = paramArrayOfFloat[0];
this.mOldAcc[1] = paramArrayOfFloat[1];
this.mOldAcc[2] = paramArrayOfFloat[2];
return bool;
}
}
</code></pre>
<p>Regarding the following codes, I have two questions:</p>
<p>1) The looping condition:</p>
<p><code>for (boolean bool = true; ; bool = false){}</code></p>
<p>This condition means that every time my loop starts, bool is set to
true. Then when the loop is finished, bool is set to false. What is
the purpose of doing so? In addition, what is the point of doing so
here?</p>
<p>2) the if condition:</p>
<p><code>if ((Math.abs(this.mOldAcc[0] - paramArrayOfFloat[0]) > 1.0F) ||
(Math.abs(this.mOldAcc[1] - paramArrayOfFloat[1]) > 1.0F) || (Math.abs(this.mOldAcc[2]
-paramArrayOfFloat[2]) > 1.0F));</code></p>
<p>The if condition is directly finished by adding a ; right after the
condition. Really have no idea why this has been done.</p>
<p>Someone please help me. Thanks very much!!!</p>
| android | [4] |
1,705,993 | 1,705,994 | set input value on new loaded form | <p>I have this link that creates a few div's in which a form is loaded via load().
This form is in a separate php file. Now i want to use the ID value of my link to set the value of an input field, but how?</p>
<p>I know i need live() for that, but the setting of the value should be automatically, and not after an event.</p>
<p>It's a situation like below</p>
<p><strong>main.php</strong></p>
<pre><code>
[..]
<a href="form.php" rel="box" id="inputvalue">
</code></pre>
<p><strong>form.php</strong></p>
<pre><code>
<form>
[..]
<input type="text" id="el">
</code></pre>
<p>I now want to set 'inputValue' (when form.php is loaded) as the new value of $("#el"), but how?</p>
<p>My javascript file is in main.php and the way i load form.php is like this</p>
<pre><code>
$("a").click(function(){
if(this.rel == "box"){
[..]
$("#container").load("form.php");
</code></pre>
<p>When the form is displayed i want to change the value of the input</p>
| jquery | [5] |
2,701,073 | 2,701,074 | Import package in project in gingerbread source code | <p>I am customizing the native Contact application in Gingerbread.
I want to call a class from native Mms Application,
I have imported the class,</p>
<blockquote>
<blockquote>
<p>import com.android.mms.ui.*; </p>
</blockquote>
</blockquote>
<p>But I am getting error,</p>
<blockquote>
<blockquote>
<p>could not find the package com.android.mms.ui</p>
</blockquote>
</blockquote>
<p>can anyone help on this?</p>
<p>Thanks</p>
| android | [4] |
350,420 | 350,421 | array with dates between two different dates | <p>I am currently working on a calender script for my personal use. Therefore I need your help :-)</p>
<p>I have two dates in format YYYY-MM-DD.</p>
<p>for example:</p>
<pre><code>2012-05-12 and
2012-05-16
</code></pre>
<p>What I need is the dates between them:</p>
<pre><code>2012-05-13
2012-05-14
2012-05-15
</code></pre>
<p>The output should be in an array. I dont now how to start anyway... so do u have a hint?</p>
| php | [2] |
992,598 | 992,599 | How can I limit the max value of number? | <p>I want to secure my page by checking if the value is digital (0,1,2,3) and if it is in the range from 0 to 120. I think <code>ctype_digit</code> function limits numbers, so can not be passed any negative number. How can I limit the max value in the simplest way?</p>
<pre><code>if (!ctype_digit($_GET['category'] AND ...) die('');
if (!ctype_digit($_GET['category'] > 120) ?
</code></pre>
<p>I was thinkig about <code>intval</code> but it can pass negative numbers.</p>
| php | [2] |
5,411,367 | 5,411,368 | Conferences or seminars for demonstrating Android applications? | <p>I am an investment management professional who recently wrote a financial application for Android. But with over 150,000 apps on Android Market, no one is really even coming across my program.</p>
<p>(I've already submitted the app to the usual reviewing/marketing sites referenced on stackoverflow to no avail.)</p>
<p>Are there any developer forums or conferences -- say, in New York or San Francisco -- where someone like me could obtain a slot to demonstrate the program in person and obtain feedback?</p>
<p>Thank you.</p>
| android | [4] |
28,059 | 28,060 | C#: Counting iEnumerable object | <p>I am trying to get the count of the elements stored in a Ienumerable object. There is no count property for this so how do i get the count for the var object?</p>
<p>Thanks</p>
| c# | [0] |
4,305,120 | 4,305,121 | unexpected ; but i cant see why | <p>Parse error: syntax error, unexpected ';' in /home/realcas/public_html/eshop/ecms/system/classes/database.php on line 29</p>
<p>This is the code on line 29</p>
<pre><code>return empty($resultArray) ? "Error in Query " ? json_encode($resultArray);
</code></pre>
<p>this is the section of code that is the issue </p>
<pre><code>public function select($table,$options,$where,$orderby)
{
$options = empty($options) ? "*" : $options;
$where = empty($where) ? "1=1" : $where;
$orderby = empty($orderby) ? "" : $orderby;
$qry = "SELECT $options FROM $table WHERE $where $orderby ";
$result = mysql_query($qry) or die(json_encode(array("error",mysql_error())));
while(($resultArray[] = mysql_fetch_assoc($result)));
return empty($resultArray) ? "Error in Query " ? json_encode($resultArray);
return json_encode($resultArray);
}
</code></pre>
| php | [2] |
740,230 | 740,231 | What does the following get(1) function do? | <pre><code>uri.getPathSegments().get(1);
</code></pre>
<p>Basically the <code>get(1)</code> part</p>
| android | [4] |
2,690,944 | 2,690,945 | In java: how to replace every instance of firsts character with second character | <p>Given a function which inputs a string and two chars, how can I create a method which removes every instance of the first char and replaces it with the second. Here is what I have so far ( I am writing this code using bluej):</p>
<p>*note the class will compile, but it does not produce the desired result.</p>
<pre><code>public class CharReplace
{
public static String Replace( String str, char c1, char c2)
{
String result = "";
for(int i = 0; i < str.length(); i = i+1) // mechanism which allows us to read through the
// string chracter by character
{
if(str.charAt(i) == c1){
c1 = c2;
}
result = result + str.charAt(i);
}
return result;
}
}
</code></pre>
<p>I appreciate your input and suggestions. </p>
<p>Thanks, </p>
| java | [1] |
3,522,445 | 3,522,446 | flash button is not loading in IE 7 | <p>flash button is not loading in IE 7</p>
<p>this is the button</p>
<p>galtech.org/mygrovephotos/js/uploadify/uploadify.swf </p>
| php | [2] |
2,050,145 | 2,050,146 | Some PHP Code is breaking the rest of the page | <p>I have an odd problem. Basicly my page works fine however after a small bit of php, everything after those lines dont load too the page.</p>
<pre><code><?php
//GET SCHOOLS
$sql = "SELECT `id` FROM `school`";
$query = mysql_query($sql) or die(mysql_error());
$numschools = mysql_num_rows($query);
echo "<select id=\"schoolselect\" class=\"schoolselect\" value=\"Select School\">
<option id='selectschool' value = \"select\" name=\"select\">Select A School</option>
";
while($result = mysql_fetch_array($query) or die(mysql_error()))
{
$school = $result['id'];
echo "<option value = \"$school\" name=\"$school\">".$school ."</option>";
}
echo "</select>";
?>
</code></pre>
<p>everything before that works, the php part works but anything after that echo "select" doesnt</p>
<p>any help would be amazing</p>
| php | [2] |
2,624,969 | 2,624,970 | Using Mapkit in iphone application | <p>I am using Mapkit in my application, i want to submit the application to appstore, is there any specific procedure need to follow for submitting the mapkit enabled or used application.</p>
<p>please help me, thanks in advance.</p>
| iphone | [8] |
1,132,561 | 1,132,562 | How to add a public key in the android project | <p>I got a public key from the android market, i want to know how to add that public key in my android project, can anyone tell me how to add the public key in my android project,</p>
| android | [4] |
2,344,165 | 2,344,166 | len(object) or hasattr(object, __iter__)? | <p>(The following is python3-related (if that matter).)</p>
<p>This this the code I've written (simplified) :</p>
<blockquote>
<pre><code>class MyClass:
def __init__(self):
self.__some_var = []
@property
def some_var(self):
return self.__some__var
@some_var.setter
def some_var(self, new_value):
if hasattr(new_value, '__iter__'):
self.__some_var = new_value
else:
self.__some_var.append(new_value)
</code></pre>
</blockquote>
<p>I want to replace when setting if their is several "values" (i.e if new_value is an iterable of, in my case, non-iterable objects) and appending if their is only one "value".
I'm concerned about the performance of hasattr so I wonder if I shouldn't use this setter instead :</p>
<blockquote>
<pre><code> @some_var.setter
def some_var(self, *args):
if len(args) > 1:
self.__some_var = args
else:
self.__some_var.append(args)
</code></pre>
</blockquote>
<p>Thank for your attention !</p>
| python | [7] |
2,279,319 | 2,279,320 | onSharedPreferenceChanged and PreferenceFragment | <p>Trying to follow the examples given in <a href="http://developer.android.com/guide/topics/ui/settings.html" rel="nofollow">http://developer.android.com/guide/topics/ui/settings.html</a> but finding it difficult as it arbitrarily flips between using and not using fragments.</p>
<p>I've taken its advice to use fragments when implementing Preferences for my app as I'm using the most recent SDK (16)</p>
<p>I'm trying to implement <code>onSharedPreferenceChanged</code> method such that I can update the preference summaries when a user chages a preference value.</p>
<p>should I implement the callback method in the fragment or the parent Activity?</p>
| android | [4] |
2,151,438 | 2,151,439 | passing an array value to querystring | <p>This is a bit of a problem that I have. I store some value into an array:</p>
<pre><code> Telco1 = a.Split(";")
For i = 0 To Telco1.Count - 1
Telco2 = Telco1(i).Split(".")
TelcoID.Add(Telco2(0))
TelcoName.Add(Telco2(1))
Next
</code></pre>
<p>Telco1 and Telco2 is Public Telco1() as String. When the user choose an TelcoID that was stored into the TelcoID array, I want that value sent to another page:</p>
<pre><code>Response.Redirect("ReloadValue.aspx?TelcoID=" + TelcoID[0])
</code></pre>
<p>Currently the error said </p>
<blockquote>
<p>Operator + is not defined for string and System.Collection.Arraylist</p>
</blockquote>
<p>Then I try to send the value over as a predefined integer like this:</p>
<pre><code>Response.Redirect("Product.aspx?TelcoID=" + "2")
</code></pre>
<p>At the next page("Product.aspx"),</p>
<pre><code>b = Request.QueryString["TelcoID"].ToString()
</code></pre>
<p>but the error that I receive states that </p>
<blockquote>
<p>value of type System.Collection.Specialized.NameValueCollection cannot
be converted to string</p>
</blockquote>
<p>I wanted to used that value that was over to this page to be used to determined the data that I wanted to get from the database to shoe in the dropdown list. May I know how do I rectify this error?</p>
| asp.net | [9] |
3,085,208 | 3,085,209 | print slowly in python, (Simulate typing) | <p>I am trying to make a textual game in python. All goes well however, I would like to make a function that will allow me to print something to the terminal, but in a fashion hat looks like typing.</p>
<p>Currently I have:</p>
<pre><code>def print_slow(str):
for letter in str:
print letter,
time.sleep(.1)
print_slow("junk")
</code></pre>
<p>The output is:</p>
<pre><code>j u n k
</code></pre>
<p>Is there a way to get rid of the spaces between the letters?</p>
<p>Thanks,
Blake</p>
| python | [7] |
5,838,979 | 5,838,980 | Renaming directory gives positive result code, but didn't rename | <p>I know it's only cosmetic but the below code should rename my directory however it doesn't. The difference is just some capitalisation - but afaik Android is fully case sensitive when it comes to filenames. Like Linux normally is too.
The rename gives a true result, indicating the operation was successful. However the directory in question is NOT renamed, and it still has two capital D's.
I have previously used the same code to rename from /DeadDropDroid to /.DeadDropDroid and that works fine. Every time I run the below code the log says "success".</p>
<pre><code>oldBasePath = new File (Environment.getExternalStorageDirectory()+ "/.DeadDropDroid/");
if (oldBasePath.exists()) {
if (oldBasePath.renameTo(new File(Environment.getExternalStorageDirectory()+ "/.DeaddropDroid/")))
Log.v(TAG, "Rename success.");
else
Log.v(TAG, "Rename fail.");
}
</code></pre>
| android | [4] |
2,434,240 | 2,434,241 | C# Xml files when creating exe application | <p>I'm planning to build my winform into an exe file. I'm just wondering what to do with the xml files that my application need?</p>
<p>I've do some research and some say you can add the xml files in the Resource folder before your create the exe file. Is this the correct way?</p>
<p>Or I need to create an setup file? When the user run the setup file, the xml files will be installed into their pc.</p>
<p>Which is the best way?</p>
<p>Note that the xml files will be modified when user run the application.</p>
| c# | [0] |
1,125,884 | 1,125,885 | Continuous Queries vs Storing and Recalling Data | <p>I would like to know which of the following methods would be best to use on a website, and a brief explanation on why. Please assume that <code>$user</code> is <code>$user = new User()</code> throughout this question </p>
<ol>
<li><p>Whether to store my data returned from a database query, as an array (<code>$user_data</code>) and then convert into an object for further referencing. (eg to get the user's name <code>$user->data->name</code>). Please note I also intend to add further to the user class for data such as permissions.</p></li>
<li><p>To keep querying the database each time I want a bit of new bit of data, so use <code>$user->data("name")</code>.</p></li>
</ol>
<p>I am new to object orientated php and couldn't find any tips on this and may also have made some mistakes in my query ideas.</p>
| php | [2] |
4,314,454 | 4,314,455 | A bug in android.view.ScaleGestureDectator? | <p>I use this code to test the ScaleGestureDectator class:</p>
<pre><code>package pirriperdos.common;
import android.os.Bundle;
import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.ScaleGestureDetector;
import android.view.ViewGroup;
import android.widget.ScrollView;
public class MainActivity extends Activity {
public class V extends ScrollView {
public V(Context context) {
super(context);
}
@Override
public boolean onTouchEvent(MotionEvent event) {
sgd.onTouchEvent(event);
if (sgd.isInProgress())
return true;
return super.onTouchEvent(event);
}
}
ScaleGestureDetector sgd;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ScrollView v = new V(this);
v.removeAllViews();
LayoutInflater.from(this).inflate(R.layout.activity_main, v);
setContentView(v, new ViewGroup.LayoutParams(1000, 1000));
sgd = new ScaleGestureDetector(this, new ScaleGestureDetector.SimpleOnScaleGestureListener());
}
}
</code></pre>
<p>But I always get a exception when I put 4 figure on the screen then take them up in some certain order.</p>
<p>It report a array out of index exception.</p>
<p>Any one has encountered the same problem? Any solution?</p>
<p>I'm debugging on my Galaxy Nexus running Android 4.1, SDK version 16.
if you need more information please tell me...</p>
<blockquote>
<p>I think no one will answer me...</p>
</blockquote>
| android | [4] |
5,187,291 | 5,187,292 | Link to php script | <p>I have a script which I can run from windows console writing "php backup.php". How to create a link to run it directly from desctop?</p>
| php | [2] |
3,780,853 | 3,780,854 | problems in ics updated devices | <p>Recently I started receive emails form my users, that they phones updated to ics, and now images that they save with my application not showing in android's gallery application after that. They say that with file explorer they can see files, but not with gallery app and that they didn't experienced any this kind of problems before ics update.</p>
<p>I'm certainly calling scanFile with MediaScannerConnection after onMediaScannerConnected event.</p>
<p><strong>Update</strong>:
I forgot mention that image mime type was set to "image/*" not to "image/jpeg" or "image/png".</p>
| android | [4] |
4,592,444 | 4,592,445 | Broadcast receiver not getting extra | <p>I have an app using a tab bar host api that I found and I am trying to use it to change activities when I receive a Sms message.</p>
<p>The receiver that was build into this tab host is the following:</p>
<pre><code>public class ChangeTabBroadcastReceiver extends BroadcastReceiver
{
@Override
public void onReceive(Context context, Intent intent)
{
int index = intent.getExtras().getInt(CURRENT_TAB_INDEX);
setCurrentTab(index);
}
}
</code></pre>
<p>This is defined in the ScrollableTabActivity.java, then the ScrollableTabHost extends this and is called in the bellow method when a Sms is reveived:</p>
<pre><code>Intent intent2 = new Intent(context,ScrollableTabHost.class);
intent2.putExtra("CURRENT_TAB_INDEX", index);
intent2.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent2);
</code></pre>
<p>There is also an OnTabChanged listener build in which prints the index of the tab to the log. When i send a text from the emulator I shows that the tab was changed to index 0 twice, no matter which index I try to set it to.
I have been looking for a while and cant find why I am getting 0 instead of the index that I send.</p>
| android | [4] |
4,306,183 | 4,306,184 | How to create a layout in android? | <p>Friends,</p>
<p>How to create a layout similar tho that of call logs in android contacts?</p>
| android | [4] |
4,801,038 | 4,801,039 | C# - updating label while adding items to ListView | <p>I have a ListView which I populate with a lot of items, over 3000. This can take up to 15 seconds.
Every time I add an item I want to update a label stating how many items have been added so far.
To do so I use this code:</p>
<pre><code>foreach (FileInfo f in dir.GetFiles("*.*", SearchOption.AllDirectories))
{
DateTime dt = GetDateTakenFromImage(Path.Combine(f.Directory.ToString(), f.Name));
count++;
labelLoadedLeft.Text = "Loading " + count + " files so far";
ListViewItem lSingleItem = lv.Items.Add(f.Name);
lSingleItem.SubItems.Add(dt.ToString("dd MMMM yyyy"));
lSingleItem.Tag = Path.Combine(f.Directory.ToString(), f.Name);
}
</code></pre>
<p>Unfortunately the label does not show until all items have been loaded.</p>
<p>I understand this has to do with the fact that I am doing a lengthy operation on thr UI thread and that I should probably be using a backgroundworker to do the work.</p>
<p>Does anyone know of good and simple examples on how to use background worker. What I have found so far is too complicated for me or too convoluted.</p>
<p>Thank you</p>
<p>Crouz</p>
| c# | [0] |
5,461,825 | 5,461,826 | Can I use python to create flash like browser games? | <p>is it possible to use python to create flash like browser games? (Actually I want to use it for an economic simulation, but it amounts to the same as a browser game)</p>
<p>Davoud</p>
| python | [7] |
3,363,868 | 3,363,869 | Why am I getting this "IndexError: string index out of range" in one case but not the other? | <pre><code>#i couldnt find the difference in the code
>>> def match_ends(words):
# +++your code here+++
count=0
for string in words:
if len(string)>=2 and string[0]==string[-1]:
count=count+1
return count
>>> match_ends(['', 'x', 'xy', 'xyx', 'xx'])
2
>>>
>>> def match_ends(words):
# +++your code here+++
count=0
for string in words:
if string[0]==string[-1] and len(string)>=2:
count=count+1
return count
>>> match_ends(['', 'x', 'xy', 'xyx', 'xx'])
Traceback (most recent call last):
File "<pyshell#26>", line 1, in <module>
match_ends(['', 'x', 'xy', 'xyx', 'xx'])
File "<pyshell#25>", line 5, in match_ends
if string[0]==string[-1] and len(string)>=2:
IndexError: string index out of range
</code></pre>
<p>I couldn't find the difference in the code except the if condition <code>if len(string)>=2 and string[0]==string[-1]:</code> in the first function and <code>if string[0]==string[-1] and len(string)>=2:</code> in the second function</p>
| python | [7] |
1,653,035 | 1,653,036 | how do we calculate increase in radiation of the phone? | <p>I like to create an application on mobile phone radiation. i am using battery status and signal strength values for this.Is this is enough??.expecting some suggestions.Am I on the right track? </p>
| android | [4] |
2,997,406 | 2,997,407 | how to create function for breadcumb using php | <p>I want to create a function and send <code>$_SERVER['HTTP_REFERER']</code> with parameter and set manual breadcrumb name.</p>
<pre><code>function breadcrumb('http://127.0.0.1/yosca_new/index.php?option=com_content&view=article&id=2&topnav=1');
</code></pre>
<p>Simple pass the parameter "previous url" and store session custom breadcrumb.</p>
<p>Please create a function for breadcrumb.</p>
| php | [2] |
439,748 | 439,749 | Google Tasks-like js control | <p>I need to imitate <a href="https://mail.google.com/tasks/ig?pli=1" rel="nofollow">Google Tasks</a> look and feel with a few minor changes.</p>
<p>Is there an open-source JavaScript control that I may reuse?</p>
<p>The main feature that I look for is "plain-text-like" feel of the in-place task editing process.</p>
| javascript | [3] |
3,979,385 | 3,979,386 | Android Open Accessory SDK error INSTALL_FAILED_MISSING_SHARED_LIBRARY | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/7294152/android-open-accessory-sdk-error-install-failed-missing-shared-library">Android Open Accessory SDK error INSTALL_FAILED_MISSING_SHARED_LIBRARY </a> </p>
</blockquote>
<p>Using the <a href="http://developer.android.com/guide/topics/usb/adk.html" rel="nofollow">Android Open Accessory Development Kit</a> and Google API 10.</p>
<p>Run in the emulator, I can install it, however when I run on my Android 2.3.4 device, Eclipse gave this error.</p>
<p>How can this be solved?</p>
<blockquote>
<p>DemoKitLaunch] Installation error: INSTALL_FAILED_MISSING_SHARED_LIBRARY </p>
<p>DemoKitLaunch] Please check logcat output for more details. </p>
<p>DemoKitLaunch] Launch canceled!</p>
</blockquote>
| android | [4] |
2,969,310 | 2,969,311 | How to hide app icon in app drawer programmatically | <p>We know how to hide an app in app drawer (launcher) referring to <a href="http://stackoverflow.com/questions/3218127/hide-one-application-in-application-menu-of-android">hide one application in application menu of android</a> , however, could we hide app itself within its code? I mean is it possible to remove activity's intent filter</p>
<pre><code><category android:name="android.intent.category.LAUNCHER" />
</code></pre>
<p>dynamically within its code.</p>
| android | [4] |
4,881,732 | 4,881,733 | Python approach to dataset manipulation | <p>Folks, we have the following problem: we've got several objects containing table data that look something like this:</p>
<p><code>{'field1':'value1','field2':'value2', ...}</code></p>
<p>At some point during runtime we need to "select" data from these objects (tables) in the same way one were to query a DB (i.e. get records in this set that matches field1 == some_value and field2==some_other_value). We don't have access to the original RDBMS or db views. We fiddled with the idea of using an intermediary DB (like sqlite) and then query it for the data as needed. </p>
<p>But it felt "smelly" to add another moving part to the app just for dataset querying purposes. So, my question is: is there a pythonic way to approach this? Should we bite the bullet and push the data to a DB, query the DB, then delete? Thanks in advance for your opinion and input.</p>
<p>The data is a list of dictionaries.</p>
| python | [7] |
5,847,925 | 5,847,926 | simple PHP syntax issues | <p><strong>SOLVED</strong>, Thank you all for your feedback! much appreciated. </p>
<p>If anyone can help with a simple syntax problem I'm having here it would be greatly appreciated. I'm still in the learning phases of php and just can't seem to figure this out. In the following code I'm assigning an array and a definition to go with it but when I try to echo the information back it's not working.</p>
<pre><code> $arr_features=array("PasswordProtect");
$arr_FeaturesDescriptions = array("Password Protection: Password Protection will be enabled, requiring participants to enter a password in order to access the event. Your password is: "echo ($_POST['PasswordProtect']);"");
</code></pre>
<p>So basically the "Your password is:" part isn't working, any ideas why? Thanks in advance.</p>
| php | [2] |
382,005 | 382,006 | Help with OAUTH twitter post from Android | <p>I want to use <a href="https://github.com/brione/Brion-Learns-OAuth" rel="nofollow">https://github.com/brione/Brion-Learns-OAuth</a> for posting twitter status from android</p>
<p>But I have problem with filling this constants. Where to find </p>
<pre><code>public static final String USER_TOKEN
public static final String USER_SECRET
public static final String REQUEST_TOKEN
public static final String REQUEST_SECRET
private static final Uri CALLBACK_URI
</code></pre>
<p>I create app in twitter , I guess USER_SECRET is Consumer secret. But I don't know other values.</p>
<p>Thanks</p>
| android | [4] |
1,683,952 | 1,683,953 | upgrading python | <p>Hi<br>
I just want to install mercurial but for all versions it needs python 2.6, I tried to use .rpm file but the only thing I got is lots of lines full of error which tells: need old versions before 2.6 and after 2.5 which is installed on my linux. any help would be appreciated.<br>
Bests</p>
| python | [7] |
4,856,375 | 4,856,376 | python string input problem with whitespace! | <p>my input is something like this </p>
<p>23 + 45 = astart</p>
<p>for the exact input when i take it as raw_input() and then try to split it , it gives me an error like this </p>
<p>SyntaxError: invalid syntax</p>
<p>the code is this </p>
<pre><code>k=raw_input()
a,b=(str(i) for i in k.split(' + '))
b,c=(str(i) for i in b.split(' = '))
</code></pre>
<p>its always number + number = astar</p>
<p>its just that when i give number+number=astar i am not getting syntax error ..!! but when i give whitespace i get sytax error </p>
| python | [7] |
4,912,540 | 4,912,541 | social networking website using ASP.NET | <p>hey friends i am gonna make a social networking website with ASP.NET should i use visual studio 2008 or 2010 and sql server 2005 or 2008 so please suggest me. i am learning from <em>chris payne</em> <strong>LEARN ASP.NET IN 21 DAYS</strong> and another book <em>andrew siemers</em> which is an excellent book.
also what is the difference between asp.net and asp.net4.0
:) thanks </p>
| asp.net | [9] |
4,935,712 | 4,935,713 | PHP: Inserting a reference into an array? | <p>I'm trying to insert into an array at a certain point:</p>
<pre><code>$hi = "test";
$var2 = "next";
$arr = array(&$hi);
$arr[] = &$var2; // this works
array_splice($arr, 1, 0, &$var2); // this doesn't
</code></pre>
<p>Why does trying to insert it into the array with splice fail and using the first method doesn't?</p>
| php | [2] |
4,842,948 | 4,842,949 | copy constructor error. please help | <p>I need someone to show me what is wrong with this code. I don't know what's wrong with it. I know the code doesn't do anything meaningful and it can't be used. I created it only to know how copy constructors work. Please, I need some "for newbie" explanation. </p>
<pre><code>class test
{
public:
int* value;
public:
int getvalue()
{return *value;};
test(int x){ value = new int(x);};
test(const test& a)
{
value=new int;
*value = a.getvalue();
};
};
</code></pre>
<h3>Edit (copied from self answer below)</h3>
<p>I tried making the getvalue() function const and it worked. The problem was that I passed the test class as a const reference and because I didn't declare the getvalue() function const the compiler thought the function was going to change something in that reference. Am I wrong? </p>
| c++ | [6] |
518,131 | 518,132 | when is static variable loaded in java, runtime or compile time? | <p>When is static variable loaded, runtime or compile time? Can someone please explain it.</p>
<p>I would really appreciate the help.</p>
<p>Thank you.</p>
| java | [1] |
5,452,973 | 5,452,974 | sdk manager not showing packages | <p>i have installed android sdk from developers.android.com and a file is downloaded named as installer_r20.0.3-windows.exe. after i run this file android sdk installed. but when i run the sdk manager after it,it is not showing any packages. It is just showing the tools installed.</p>
<p><img src="http://i.stack.imgur.com/zAkLB.png" alt="the snapshot of the sdk manager is below"></p>
<p>i have searched on this site, many of us written solution is to set the proxy setting, but i am using a wireless home network in my laptop and don't have any proxy setting specified in my internet options..............</p>
<p>can anyone plzz help me with this .....i am just stuck at this point .... </p>
<p>plzzz do tell me what is the problem and how to solve it.</p>
<p>thanx in advance...</p>
| android | [4] |
4,708,158 | 4,708,159 | Active data copying | <p>Is this expression correct?</p>
<pre><code>{
char a;
char *temp;
for(int j = 0; j < len; j++)
{
strcpy(&temp[j], (char*)a);
}
}
</code></pre>
<p>in this code <code>a</code> gets updated externally by the user input/key stroke. I want to copy all incoming/updated <code>a</code> to the <code>temp</code> as an entire string.</p>
| c++ | [6] |
4,540,896 | 4,540,897 | dropdown list Query String Parameter | <p>Hello everyone how you guys doing? I have a dropdown list that won't populate data values from database using sql datasource. When i use the code behind, i was able to populate the data to the dropdown list. I dont know how to pass the Query String Parameter using code behind since i am new in asp.net.</p>
<p>This is the code behind:</p>
<pre><code>Imports System.Data.SqlClient
Partial Class PhotoAlbum
Inherits System.Web.UI.Page
Dim oConn As New SqlConnection("Data Source=.\SQLEXPRESS;" & _
"AttachDbFilename=|DataDirectory|\ASPNETDB.MDF;" & _
"Integrated Security=True;User Instance=True")
Dim oCmd As New SqlCommand()
Dim oDR As SqlDataReader
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
oConn.Open()
oCmd.CommandText = "SELECT [CategoryID], [Name] FROM Categories ORDER BY [Name]"
oCmd.Connection = oConn
oDR = oCmd.ExecuteReader()
Me.categories.DataSource = oDR
Me.categories.DataTextField = "Name"
Me.categories.DataValueField = "CategoryID"
Me.categories.DataBind()
oDR.Close()
oConn.Close()
End Sub
End Class
</code></pre>
<p>I will like to include the following information from sqlDatasource to the codebehind:</p>
<pre><code>SelectCommand="SELECT [CategoryID], [Name] FROM [Categories] WHERE ([UserId] = @UserId) ORDER BY [Name]">
<SelectParameters>
<asp:QueryStringParameter Name="UserId" QueryStringField="ID"/>
</code></pre>
<p>As you can see from the code behind, i was able to add :</p>
<pre><code>"SELECT [CategoryID], [Name] FROM Categories ORDER BY [Name]".
</code></pre>
<p>But i will like to add all of this:</p>
<pre><code>SelectCommand="SELECT [CategoryID], [Name] FROM [Categories] WHERE ([UserId] = @UserId) ORDER BY [Name]">
<SelectParameters>
</code></pre>
<p>Thank you guys in advance</p>
| asp.net | [9] |
3,633,313 | 3,633,314 | Getting the file browser twice | <p>I have a little application which can be found here: <a href="http://templater.pmueller.dev.xiag.ch/frontend/show/id/3/authkey/789" rel="nofollow">templater.pmueller.dev.xiag.ch/frontend/show/id/3/authkey/789</a> If the site is down, try again in an hour. They are experiencing problems atm. Also everything is quite beta and it's my first bigger jQuery project.</p>
<p>If you drag an element from the left to the right, you can double click on the left handed little images as well as on the text.</p>
<p>My problem is that if i double click on the images, the code gets called twice. If you don't experience this, reload the page. Normally, a newly added element doesn't show this problem, but as soon as you reload, the bug is there.</p>
<p>My guess is some messed up event handlers, but I'm too new for debugging that correctly.</p>
<p>Here are some code snippets:</p>
<p>jquery.InlineEditor.js</p>
<pre><code> $(this).on("dblclick", '.editor-img', function() {
if($(this).is('img')) {
$("#imgUpload").attr('action', '/frontend/upload/width/' + $(this).width() + '/height/' + $(this).height());
$('#imageInput').click();
$('body').data('clickedElement', this);
}
});
</code></pre>
<p>I also thought of just unbind the event before i bind it again, but I really want to know what to do and how a nice solution to this problem looks like.</p>
<p>Thanks</p>
| jquery | [5] |
1,519,210 | 1,519,211 | keynav jquery plugin : How to change first element of navigation? | <p>I have a simple example:</p>
<pre><code><head>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/jquery.keynav.js"></script>
</head>
<style>
.select { color: red }
</style>
<a class="test" href="">A</a>
<a class="test" href="">B</a>
<a class="test" id="test" href="">C</a>
<a class="test" href="">D</a>
<script>
$.keynav.reset();
$('.test').keynav('select','');
$('#test').focus();
$('#test').removeClass().addClass('select');
</script>
</code></pre>
<p>I want to begin navigation from element C. But it is example not work: navigation begins from element A. Why ?</p>
| jquery | [5] |
5,893,016 | 5,893,017 | How to combine these two javascript/jquery scripts | <p>I have an id #navigation li a and a class .menu-description . I want to change text color of the class .menu-description when hovered on #navigation li a</p>
<p>My jquery so far:</p>
<pre><code><script>
$(document).ready(function() {
$('#navigation li a').mouseover(function() {
//Check if element with class exists, if so change it to new
if ($('div.menu-description').length != 0)
$('div.menu-description').removeClass('menu-description').addClass('menu-descriptionnew');
//Check if element with class 'menu-descriptionnew' exists, if so change it to 'menu-description'
else if ($('div.menu-descriptionnew').length != 0)
$('div.menu-descriptionnew').removeClass('menu-descriptionnew').addClass('menu-description');
});
});
</script>
</code></pre>
<p>second script:</p>
<pre><code><script>
$(document).ready(function() {
$('.menu-description').hover( function(){
$(this).css('color', '#EEEEEE');
},
function(){
$(this).css('color', '#000000');
});
});
</script>
</code></pre>
<p>How to combine these to in order to reach for my wanted result?</p>
| javascript | [3] |
5,382,353 | 5,382,354 | Android: How to set logo in all activities of android application | <p>I want to set Logo before the app name in activities?
Please anyone help me to set logo(icon) in activity page in top right corner..</p>
| android | [4] |
2,905,663 | 2,905,664 | Showing A Waiting Image While The Page.Load event does its stuff? | <p>I have a page that on page load exectutes a lot of methods.. A few ping off and grab some external pages and strip out content to display etc.. etc..</p>
<p>Problem is as this can take quite a few seconds, the page just sort of hangs while all this is going on in the background... I want to be able to display the page with an animated GIF saying 'Working' or something... And still in the background the methods in the page load are populating the GridView or whatever and when ready show the result? Any ideas? Do I have to use an Udate Panel or something?</p>
| asp.net | [9] |
3,047,667 | 3,047,668 | Getting error while sending mail? | <p>when i am sending mail in my web application i am getting this erro.</p>
<p>I AM GETTING THIS ERROR. The element may only appear once in this section. (C:\Inetpub\vhosts\XXX.com\httpdocs\web.config line 64) </p>
<pre><code> <system.net>
<mailSettings>
<smtp>
<network host="webmail.xxx.com" port="25" userName="info@xxx.com" password="asdf" defaultCredentials="false"/>
<network host="webmail.yyy.com" port="25" userName="info@yyy.com" password="asdf12" defaultCredentials="false"/>
</smtp>
</mailSettings>
</system.net>
</code></pre>
| asp.net | [9] |
2,309,160 | 2,309,161 | Need help,Screen didn't turn on after I change Activity's theme | <p>I'm making my alarm app. There is an Activity to show alarm infomation.
I want turn on the screen and unlock it. I wrote these code</p>
<p><b>AlarmActivity.java:</b></p>
<pre>
public class AlarmActivity extends Activity {
......
void onCreate(Bundle bl) {
.....
final Window win = getWindow();
win.requestFeature(android.view.Window.FEATURE_NO_TITLE);
win.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
| WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
| WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
| WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
LayoutInflater inflater = LayoutInflater.from(this);
setContentView(inflater.inflate(R.layout.alarm, null));
}
......
}
</pre>
<p><b>AndroidManifest.xml</b></p>
<pre>
{activity android:name="AlarmTaskActivity"
android:excludeFromRecents="true"
android:theme="@android:style/Theme.Wallpaper.NoTitleBar"
android:launchMode="singleInstance"
android:taskAffinity=""
android:configChanges="orientation|keyboardHidden|keyboard|navigation"/}
</pre>
<p>It's ok,but when I change<br/>
<b>android:theme="@android:style/Theme.Wallpaper.NoTitleBar"</b>
to
<b>android:theme="@android:style/Theme.Dialog"</b>
the screen did not turn on nor unlock, I am really confused....</p>
<p>Can you please tell me how to make the screen turn on and unlock when I use "@android:style/Theme.Dialog"?</p>
<p>Thanks</p>
<p>by the way,I have android 2.0 in my test device. </p>
| android | [4] |
1,338,603 | 1,338,604 | How should i write Response.Redirect() in asp.net | <p>In asp.net two overload method of Response.Redirect() exist.</p>
<blockquote>
<ol>
<li><p>Public Sub Redirect ( _ url As String )</p></li>
<li><p>Public Sub Redirect ( _ url As String, _ endResponse As Boolean _ )</p></li>
</ol>
</blockquote>
<p>I would like to know the diffrence between these two? and which one should i use?</p>
| asp.net | [9] |
4,858,647 | 4,858,648 | Android library - ClassDefNotFoundError - class not in classes.dex | <p>I have an Android library (Java code) that I share among multiple Android application projects using Eclipse. For application projects I've created in the past I'm able to reference the Android library and use it at runtime no problem. But now for any new Android application project I create with references to my library, I get ClassDefNotFoundErrors whenever I reference classes in the library at runtime.</p>
<p>This is only a problem for Android libraries; for general Java libraries I'm still able to reference them from new Android application projects no problem.</p>
<p>Using dex2jar I found that in my application's classes.dex file the library's classes are <em>not</em> present. Whereas for my older application projects where everything works, the library's classes <em>are</em> present in classes.dex.</p>
<p>Note that the working-case apps and the non-working-case apps both reference the same Eclipse project on disk. So the problem is not in the library eclipse project, but rather in the application Eclipse project.</p>
<p>Can anyone tell me what I might be doing wrong? Or more generally how to debug the process by which Eclipse creates the Android application's classes.dex?</p>
<p>Here's a screenshot of the application project, referencing my "testlib" Android library project. I've tried moving the reference up and down the list, checking the checkbox, etc.
<img src="http://i47.tinypic.com/2ntzord.png" alt=""></p>
<p>Thanks,
Dave</p>
| android | [4] |
4,095,953 | 4,095,954 | How to check ensure a array does not contain the same element twice | <p>I have a loop which assigns randomly generated integers into an array.
I need a way to ensure the same integer is not input into the array twice.</p>
<p>I figured creating a loop inside the overall loop would work but I am unsure on what to execute here.</p>
<pre><code>int wwe[] = new int[9];
for(int i = 0; i < 9 ; i++){
int randomIndex = generator.nextInt(wwe.length);
wwe[i] = randomIndex;
System.out.println(wwe[i]);
System.out.println("########");
for(int j = 0; j < 9; j++){
System.out.println("This is the inner element " + wwe[j]);
}
}
</code></pre>
| java | [1] |
4,205,792 | 4,205,793 | I'm trying to make a void to check if something is true, and if something is, make a string say something depending on what was true | <pre><code> public void sortingFamilyName(Player player) {
if (player.Zamorak == true) {
godFamily = "Zamorak";
}
if (player.Saradomin == true) {
godFamily = "Saradomin";
}
if (player.Guthix == true) {
godFamily = "Guthix";
}
if (player.Zaros == true) {
godFamily = "Zaros";
}
if (player.Seren == true) {
godFamily = "Seren";
}
if (player.Bandos == true) {
godFamily = "Bandos";
}
if (player.Armadyl == true) {
godFamily = "Armadyl";
}
}
</code></pre>
<p>Theres smallish trouble. It doesn't work. How can I make it so, if Armadyl is true, godFamily would be "Armadyl"?</p>
| java | [1] |
1,720,996 | 1,720,997 | How to sort array without using sort method in C# | <p>How to sort array without using sort method in C#</p>
| c# | [0] |
3,841,767 | 3,841,768 | "reveal" an image on iphone | <p>i would like to reveal an image on an UIView:</p>
<ol>
<li>showing an empty screen</li>
<li>slowly reveal the image from to to bottom</li>
</ol>
<p>Any ideas ?</p>
| iphone | [8] |
4,264,021 | 4,264,022 | PHP How to check if an array key equals a certain value? | <p>How do I check that an array key equals a value with an array like this:</p>
<p><code>Array ( [0] => stdClass Object ( [subCategory] => All Headphones [description] => [image] => ) [1] => stdClass Object ( [subCategory] => Behind-the-Neck Headphones [description] => [image] => ) [2] => stdClass Object ( [subCategory] => Clip-On Headphones [description] => [image] => ) [3] => stdClass Object ( [subCategory] => Earbud Headphones [description] => [image] => ) [4] => stdClass Object ( [subCategory] => Kids' Headphones [description] => [image] => ) )
</code></p>
<p>I've tried using this code:</p>
<pre><code>if(array_key_exists('subCategory',$array) {
echo "Exists";
}
</code></pre>
| php | [2] |
2,452,415 | 2,452,416 | Function.prototype.propertyname === Object.propertyname is true? | <p>In trying to better understand the prototype behind javascript, I have stumbled upon the following, which I am unable to make sense of so far. </p>
<p>I understand that functions are a first class object, but I don't get why Object gets this property after setting the property on Function.prototype </p>
<pre><code>Function.prototype.foo = 'bar';
Object.foo // Object now has this property and returns 'bar'
Object.foo === Function.prototype.foo // returns true
</code></pre>
| javascript | [3] |
3,525,617 | 3,525,618 | convert Base64 string to image in android | <p>Hello
In an android application we are receiving a byte64 string.I need to convert these strings to images.
I tried getting it but couldnot find any.
Please let me know your valuable suggestions</p>
<p>Thanks in advance :)</p>
| android | [4] |
4,478,230 | 4,478,231 | How to get Android screen height minus status bar in pixel? | <p>I am using this thick but it returns "0"</p>
<pre><code> View content = getWindow().findViewById(Window.ID_ANDROID_CONTENT);
int viewHeight = content.getHeight();
</code></pre>
<p>How to do so?</p>
| android | [4] |
1,436,573 | 1,436,574 | android: check if value is present in Shared Preferences | <p>I'm creating Shared Preferences as follows</p>
<pre><code>preferences = getSharedPreferences("text", 0);
final Editor editor = preferences.edit();
String s1 = serverIP.getText().toString();
String s2 = serverPort.getText().toString();
String s3 = syncPass.getText().toString();
String s4 = proxyServer.getText().toString();
String s5 = proxyPort.getText().toString();
editor.putString("SERVERIP", s1);
editor.putString("SERVERPORT", s2);
editor.putString("SYNCPASS", s3);
editor.putString("PROXYSERVER", s3);
editor.putString("PROXYPORT", s3);
</code></pre>
<p>and onCreate i want to display the values in new set of TextView, but the first time i will not have any values stored in the shared preferences and will get a NULL Pointer exception.... <strong>So i want to know if there is any inbuilt method which can check if the shared preferences contains any value or no</strong>,,, so that i can check for the value presence and then Replace the New set of textviews with the preferences value.. </p>
| android | [4] |
3,767,382 | 3,767,383 | How to get the caller class in Java | <p>I want to get the caller class of the method, i.e. </p>
<pre><code>class foo{
bar();
}
</code></pre>
<p>in the method bar, i need to get the class name <code>foo</code>, and i found this method:</p>
<pre><code>Class clazz = Reflection.getCallerClass(1);
</code></pre>
<p>however, i noticed that <code>getCallerClass</code> is a native method, so am wondering whether there are some side effects here.</p>
<p>are there any other choices? thanks in advance.</p>
| java | [1] |
5,042,055 | 5,042,056 | How can I get files from the iDisk programmatically? | <p>I need to write an iPhone app that allows the user to download and use files (more specifiably, video files) that are on the Mobile Me iDisk. Is this possible? I was not able to find an iDisk API for Objective-C.</p>
| iphone | [8] |
4,204,857 | 4,204,858 | Testing for object equality by comparing the toString() representations of objects | <p>Following on from <a href="http://programmers.stackexchange.com/questions/149001/are-there-any-situtations-where-having-a-data-model-in-which-all-your-enititie">this question</a> - how do you explain to someone that this is just crazy!:</p>
<pre><code>boolean someMethod(Map<String, Object> context) {
Object object = context.get("someProperty")
Object another = context.get("anotherProperty")
return object.toString().equals(another.toString());
}
</code></pre>
<p>Apparently the reason for why <code>Object.equals(...)</code> is not used is that "what's contained in the Map is not concretely known, but is definitely known to be one of the primitive wrappers i.e. <code>String</code>, <code>Double</code>, <code>Boolean</code>, etc... and that <code>Boolean.TRUE</code> is required to be <code>equal(...)</code> to the <code>String</code> "TRUE"".</p>
| java | [1] |
2,150,279 | 2,150,280 | Admob with version 4.0 only? | <p>I am looking at introducing admob to my application which is developed in version 2.1 so it can support all devices. However I think that I just read that admob will not work for any devices that are prior to 3.2 or 4(cant remember) and that the most recent admob SDK should be downloaded or it will not work.</p>
<p>Can you confirm my undertsanding and if so what should I do to make ti run on olderversions?
Thank you</p>
| android | [4] |
4,940,961 | 4,940,962 | limiting number of letters for registering a new user name | <p>I have a forum and visitors can register user names with more than 20 letters, how can I deny those visitors to register with a (long) user names?</p>
<p>the registration form is using PHP language.</p>
<p>thanks,</p>
| php | [2] |
4,754,849 | 4,754,850 | Hiding Source code | <p>i have a problem in my website.i need to disable both right click and view source option in browsers menu for all webpages.There may be some other ways to get source code,that doesn't matters.i have alredy disabled right click.so please help me if there is any way to supress browsers view source option.</p>
<p>Thanks in advance.</p>
| asp.net | [9] |
2,835,854 | 2,835,855 | MVC Framework that is similar to ASP.NET MVC but for Winform | <p>I know there are MVC for Winform (MVC# etc.) but if have to develop on ASP.NET MVC and then on Desktop I don't want to have 2 different frameworks so is there anything close to ASP.NET MVC but for Winform ?</p>
<p>What I mean is that the specific part of ASP.NET which is url routing for example should be replaced by something on winform so that one can readily switch from one platform to the other.</p>
<p>This seems rather common sense needs to me so why doesn't this seem to exist or taken into account at Microsoft ? </p>
<p>All focus seems to be on web development nowadays which I regret because there are many desktop apps in enterprise that have the same level of complexity as web app and would benefit from not reinventing the wheel and use a widely spread MVC framework.</p>
| c# | [0] |
433,357 | 433,358 | Loop through included files in php | <p>I have this code snippet here:</p>
<pre><code><?php
include('a.php');
include('b.php');
include('c.php');
include('d.php');
include('e.php');
?>
</code></pre>
<p>I would like to have a loop run through this file and execute each of these files once. How can i go about this? I am new to php.</p>
| php | [2] |
5,762,043 | 5,762,044 | trouble putting one function to another | <p>what i'm trying to do is to read each line of the file then put it into other function called handleLine which then creates output, numericgrade calculates the overall percentage and then lettergrade assigns a grade.</p>
<p>for example in file i have
"name, last name", classid, exam, final
and i want it to output
full name, score , grade</p>
<pre><code>def main():
fin=open("scores.csv", "r")
fout=open("grades.csv", "w")
fout.write('"Name", "Score", "Grade"\n')
line=fin.readlines()[1:]
for line in line:
line=line.split(",")
handleLine(line)
fout.write('"' + lname + "," + fname + '" ,' + score +", " + grade+ ' ", ')
def numericGrade(midterm, final):
score=0.4*float(midterm) + (0.6 * float(final))
def letterGrade(score):
grade = None
if score >= 90:
grade = "A"
elif score >= 80:
grade = "B"
elif score >=70:
grade ="C"
elif score >= 60:
grade = "D"
else:
grade = "F"
def handleLine(line):
fout=open("grades.csv", "w")
fname= line[1][1 : -1]
lname= line[0][1 : ]
midterm= line[2]
final = line[3]
numericGrade(midterm, final)
score = numericGrade(midterm,final)
grade = letterGrade(score)
return lname, fname, score, grade
if __name__=="__main__":
</code></pre>
<p>main()</p>
<p>I'm having trouble putting one function to another, now it says that lname is not defined in line 14. Im really lost now. </p>
<p>EDIT:
I have fixed the </p>
<p>lname, fname, score, grade= handleLine(line)</p>
<p>but i have an error now in line 14</p>
<p>TypeError: cannot concatenate 'str' and 'NoneType' objects</p>
| python | [7] |
3,148,079 | 3,148,080 | I want to get unique set of n*n arrays which are including only 0 or 1 at random location in c++ | <p>I want to acquire set of n*n arrays including 0 or 1 </p>
<p>But, each element has to be different each other.</p>
<p>For example,</p>
<pre><code>arr[3][3] = {{0,1,0},
{1,0,0},
{1,1,1}}
arr2[3][3] = {{0,1,1},
{1,1,1},
{0,0,1}}
</code></pre>
<p>Like above, I need unique array.</p>
| c++ | [6] |
824,456 | 824,457 | set folder read only to false | <p>Currently my code to set the folder read only to <strong>false</strong>.</p>
<pre><code>var di = new DirectoryInfo("C:\\NightlyBuild");
foreach (var file in di.GetFiles("*", SearchOption.AllDirectories))
file.Attributes &= ~FileAttributes.ReadOnly;
</code></pre>
<p>However, I did this to find the file in smallest file by sorting them in decesending order:</p>
<pre><code>string path = "C:\\NightlyBuild\\";
var files = Directory.GetDirectories(path, "NightlyBuild.*");
foreach(var file in files)
Console.WriteLine(file);
foreach(var file in files.OrderByDescending(x=>x).Skip(int.Parse(args[0])))
Console.WriteLine(file);
foreach(var file in files.OrderByDescending(x=>x).Skip(int.Parse(args[0])))
Directory.Delete(file, true);
</code></pre>
<p>Any way to alter this code so that whatever file that i delete?<br>
I just want to set that file read-only to false? This file is actually a folder fyi</p>
| c# | [0] |
5,506,551 | 5,506,552 | Changing language from my app works weirdly | <p>I am changing the language in <code>MainActivity.onCreate()</code> like this:</p>
<pre><code>Locale locale = new Locale("cs");
Configuration config = getResources().getConfiguration();
config.locale = locale;
getResources().updateConfiguration(config, getResources().getDisplayMetrics());
</code></pre>
<p>It works OK at first look, the layout is in he correct language. But when I open the menu, it is localized to the system default language (English)! To find out what's happening I checked every 30ms (via <code>Timer</code>) what is the value of <code>getResources().getConfiguration().locale.getLanguage()</code>. About 50ms after <code>onResume()</code> is finished, the language magically changes from "cs" to "en".</p>
<p>I tried to set it back after I detect the change, but it was not working. What worked was if I set the language again to "cs" in <code>onCreateOptionsMenu()</code>.</p>
<p><strong>Important note:</strong> this happens only if the app is started after it was previously killed. By "killed" I don't mean <code>MainActivity.finish()</code> is called but rather that the app is completely removed from the memory including static fields (in practice this happens after install or if the system kills it due to low memory).</p>
<p><strong>UPDATE:</strong> Another issue I noticed is that when I change the orientation of the phone to landscape, my app still uses portrait layout and not the layout from layout-land folder.</p>
| android | [4] |
1,676,518 | 1,676,519 | android - difference between static reference and reference inside Application class? | <p>suppose i have a reference to an instance of a class , which doesn't have any direct/indirect reference to problematic objects (like context,views,...) .</p>
<p>are there any differences between using this reference in a static reference and using it inside the class that extends the <code>Application</code> class?</p>
<p>i mean , in both ways the referenced object will be freed only when the process is killed (or when there are no references to it) , right?</p>
<p>maybe there is a difference when using multiple processes ?</p>
| android | [4] |
3,459,734 | 3,459,735 | Whats the quickest way to get rid of all the properties of a an object in javascript? | <p>I have an on object like so</p>
<pre><code>var obj = {};
function set()
{
obj.x1 = 20;
obj.y1 = 35;
obj.x2 = 60;
obj.y2 = 55;
...
}
</code></pre>
<p>Whats the quickest way to delete/reset all of the properties of obj?</p>
| javascript | [3] |
4,746,089 | 4,746,090 | How to sort NSMutableArray in ascending order, iPhone? | <p>I have SQLite Database(DB) and made this to model class and taken the data of DB in NSMutableArray. My DB is similar to this DB.
<strong>StudentName | RegisterNumber | DatesOfJoin(DoJ)</strong>
I am displaying the DoJ in tableView successfully, but I wanna sort the DatesOfJoin in Ascending order and Descending order in tableView.
Any help would be appreciated and Thanks you in advance.</p>
| iphone | [8] |
702,156 | 702,157 | How to change the border and separator color of spinner widget | <p>I have customised the <code>spinner</code> items background into black color.But border around spinner and the separartor between each spinner item is in white color.
I want to change separator color and border to dark gray color.</p>
<ul>
<li>How can i change these color?</li>
<li>Is spinner uses list view or some other as parent to populate items in spinner?</li>
<li>If so can i change the separator background of parent view?</li>
</ul>
| android | [4] |
2,722,260 | 2,722,261 | The difference between putting functions into an object and prototyping them? | <p>What's the difference between adding functions to an object and prototyping them onto the object?</p>
<p>Prototyping allows the object/model to call itself?</p>
| javascript | [3] |
3,862,014 | 3,862,015 | PHP Blackjack aces | <p>The PHP blackjack script is simple, I have an array of cards and I select a random one and add it and it's also pretty easy to keep the count the hard part comes in with the aces.</p>
<p>Is there any efficient method to counting them except bruteforcing? Theoretically it would be possible (although highly unlikely) to get 4 aces in a row, how would I make it count as 14 and not 44, 34, 24 etc? (closest to 21 without getting over it)</p>
| php | [2] |
3,372,693 | 3,372,694 | this property is not supported by object? | <pre><code>$(document).ready(function(){
('#mainField').click(function(){
$("#editor").animate({width: 985, height: 200}, 1500);
$("#closeEditor").css("display", "inline");
});
});
</code></pre>
<p>This piece of code doesn't work, whats wrong?!
It says: "this property is not supported by object" at the 2nd row..?</p>
| jquery | [5] |
5,881,774 | 5,881,775 | How to send just a string with http Post on Android? | <p>i need to send a string to a server, but the only way i know to is by using namevaluepairs, but that sends the key and a value i just want to send one string, how do i do that?</p>
<pre><code>HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://10.0.2.2:1455/Android/Android.svc/GetCompanyBusinessAreas");
try
{
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("", companhiaIdS));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
Log.i("Enviando:", nameValuePairs.toString());
// Execute HTTP Post Request
HttpResponse response = httpclient.execute(httppost);
Log.i("Resposta:", response.getEntity().toString());
HttpEntity responseEntity = response.getEntity();
</code></pre>
<p>what can i use instead of namevaluepairs, because it send a list and the server is excpecting just one string?</p>
| android | [4] |
5,700,477 | 5,700,478 | ScriptManager.RegisterHiddenField in Chrome | <p>I'm working with some code that utilizes the ScriptManager.RegisterHiddenField to keep track of modifications to a datamodel. It works fine in IE and FF, but Chrome is having trouble. A simple example of the problem occurs if you add something like:</p>
<pre><code>protected void Page_Load(object sender, EventArgs e)
{
ScriptManager.RegisterHiddenField(this, DateTime.Now.ToString(), "keith");
}
</code></pre>
<p>on a page. When you first load the page it works correctly, you will see a hidden field like:</p>
<pre><code><input type="hidden" name="12/17/2010 9:55:13 AM" id="12/17/2010 9:55:13 AM" value="keith" />
</code></pre>
<p>However, if you do anything that requires a post back it will not generate a new date/time for the name of the hidden field. It usually generates a cached version of the field from hours before. Any thoughts on why Chrome performs this way with RegisterHiddenField? Thank you for any help.</p>
<p>Keith</p>
| asp.net | [9] |
394,099 | 394,100 | questions about "Beginning Android Games" by Mario Zechner | <p>I refer to <a href="http://stackoverflow.com/questions/2837925/good-book-for-android-game-development">Good book for Android game development</a>.
Before I buy the book, I just need to know, do the examples in the book use a game engine or no? Does the book recommend games be written in java? Does the author ever mention c++ for Android Games and when you would use it? Does the section on 3D explain how to set up the development environment for 3D games (such as it does for setting up JDK and Android SDK)? Does the book provide example source code for 3D games?</p>
| android | [4] |
1,156,773 | 1,156,774 | Why num = 1 - -"2" equals 3 | <p>Titles says it but again:</p>
<p>If we do:</p>
<pre><code>num = 1 + +"2";
alert(num); // 3
</code></pre>
<p>I know that with <code>+"2"</code>, addition of <code>+</code> converts string into number. But:</p>
<pre><code>num = 1 - -"2";
alert(num); // 3
</code></pre>
<p>Why is it so? I was expecting <code>-1</code> eg <code>-"2" = -2</code></p>
| javascript | [3] |
80,919 | 80,920 | Are XHDPI images meant for use with retina displays in Android? | <p>Should we use XHDPI images for retina display in Android? If not, where should I place images/assets for the Samsung Galaxy S3.</p>
<p><strong>Update:</strong><br>
I found a useful artical:<br>
<a href="http://blog.blundell-apps.com/list-of-android-devices-with-pixel-density-buckets/" rel="nofollow">List of Android Devices with pixel density buckets</a></p>
| android | [4] |
3,941,535 | 3,941,536 | How can i know that the AsyncTask that ran on the background is done ? | <p>There is something that i don't understanding here ... </p>
<p>I define class </p>
<pre><code>public class SendStringToServer extends AsyncTask<String, Integer, Boolean>
{
.
.
.
}
</code></pre>
<p>Now, i implimented the 'onPostExecute' method and i calling this background action from the main activity by using</p>
<pre><code> new SendStringToServer().execute("stringToSend");
</code></pre>
<p>Now, How can i know from the main activity that this action was done ?
Hiw can i know from the main activity that this string was send already ? </p>
| android | [4] |
3,048,749 | 3,048,750 | How to create and remove application shortcut into home screen? | <p>I am creating a application shortcut. It's working fine. But i can't remove this shortcut. How to remove my application shortcut. In my home screen contains lot of application shortcut. How to remove that..<br>If it is possible please send information for how to remove application shortcut. Otherwise if it is not possible send Reason. Please reply your answers and comments are valuable me. Thanks.<br>My sample code is here...</p>
<pre><code> Button btnShortcut = (Button) findViewById(R.id.btnCreateShortcut);
btnShortcut.setOnClickListener(new View.OnClickListener()
{
public void onClick(View arg0)
{
Intent shortcutintent = new Intent("com.android.launcher.action.INSTALL_SHORTCUT");
shortcutintent.putExtra("duplicate", false);
shortcutintent.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.app_name));
Parcelable icon = Intent.ShortcutIconResource.fromContext(getApplicationContext(), R.drawable.ic_launcher);
shortcutintent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, icon);
shortcutintent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, new Intent(getApplicationContext() , MyActivity.class));
sendBroadcast(shortcutintent);
}
});
</code></pre>
<p>My Android Manifest.xml code is here...</p>
<pre><code><uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/>
<uses-permission android:name="com.android.launcher.permission.UNINSTALL_SHORTCUT"/>
</code></pre>
| android | [4] |
771,238 | 771,239 | android don't show icon after first launch...? | <p>i have a small problem: can i show the icon of my application in drawer only so long as it is done the first time?</p>
<p>I found the code (in the manifest to make) for don't appear (icon is invisible):</p>
<pre><code><application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".SanvalentinoNumActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<!-- ICON INVISIBLE -->
<data
android:host="mocha"
android:path="/RTT/reset"
android:scheme="content" />
</intent-filter>
</activity>
</application>
</code></pre>
<p>but i would like that or my app autostar afetr the downloading or that the icon become invisible after the first launch..</p>
<p>help me please...</p>
| android | [4] |
3,359,629 | 3,359,630 | jQuery Framework Support - are there any companies that do support for jQuery? | <p>I'm looking into support models between commercially supported client side frameworks and Microsoft’s Support for JQuery. My intent is to determine if there is a risk/gap in support as development shifts more towards client side interactions.</p>
<p>Does anyone have an opinion or can suggest the best solution? Thanks!</p>
<p><strong>I realized that I have a better question about this. If I were working on a huge project and needed some dedicated paid help with a jQuery problems, is there a company I could get this help from?</strong> </p>
| jquery | [5] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.