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 |
|---|---|---|---|---|---|
5,715,776 | 5,715,777 | Is it possible to resize images to specific size? | <p>I have an application which has around 800 images. Is there any way to re size the images to specific size. I have tried using the following code:</p>
<pre><code>UIImage *image = [[UIImage imageNamed:recipeObj.recipeImage]
_imageScaledToSize:CGSizeMake(64.0f, 61.0f)
interpolationQuality:1];
cell.imageView.image = image;
</code></pre>
<p>This code snippet gives me a warning. Is there any other alternative way for resizing images?</p>
| iphone | [8] |
5,690,058 | 5,690,059 | Is this a reliable way to check the REQUEST_METHOD? | <p>In my class, <code>AController</code>, I have the following method:</p>
<pre><code>private function determineRequestMethod()
{
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
$this->requestMethod = AController::POST;
}
else
{
$this->requestMethod = AController::GET;
}
}
</code></pre>
<p>This method is called from the constructor. <code>POST</code> and <code>GET</code> are class constants, and <code>requestMethod</code> is a class variable.</p>
<p>PS - <code>$_SERVER['REQUEST_METHOD']</code> does work on my server.</p>
<p>I have updated the method to specifically check for <code>GET</code> and to throw an exception when the request method is not <code>GET</code> or <code>POST</code>:</p>
<pre><code>private function determineRequestMethod()
{
if($_SERVER['REQUEST_METHOD'] == AController::POST)
{
$this->requestMethod = AController::POST;
}
else if($_SERVER['REQUEST_METHOD'] == AController::GET)
{
$this->requestMethod = AController::GET;
}
else
{
throw new Exception('Unexpected request method [' . $_SERVER['REQUEST_METHOD'] . '].');
}
}
</code></pre>
| php | [2] |
4,772,950 | 4,772,951 | I just woke up one morning and my iPhone 3GS had the glass on its coverface cracked? | <p>I just woke up one morning and my iPhone 3GS had the glass on its coverface cracked?!!? I had a friend who has a PhD in Physics from Stanford tell me this is due to a flaw in the manufacture of the screen causing a very low/cold temperature to crack the screen. Has anyone else had this happen and gotten Apple to replace their phone?</p>
| iphone | [8] |
5,727,015 | 5,727,016 | is it always safe to use the first element of the array returned by split? | <p>I'm pretty sure the answer is yes, but I just want to confirm that there is never a situation where a non null string (regardless of what it contains) would return anything but a valid String as the first member of the array returned by split. </p>
<p>In other words.</p>
<pre><code>String foo = ""; // or "something" or "a b c" or any valid string at all
String[] bar = foo.split(",")[0];
</code></pre>
<p>My understanding is that bar will never be null and the assignment line has no way to fail. If the delimiter is not found in the string it just returns foo in its entirety as the first element of the returned array.</p>
| java | [1] |
5,921,697 | 5,921,698 | list files on network drive | <p>I have a network drive named "EAGLE" that I mounted in ubuntu. I am trying to list every file on the root of the drive. I cannot seem to get the path correct. The drive is not offsite and is located in the office.</p>
<p>python</p>
<pre><code>for item in glob.glob('\\\\localhost\\EAGLE\\Data\\*'):
print item
</code></pre>
| python | [7] |
1,574,117 | 1,574,118 | how can i read an element except specific child element? | <p>sorry for bad english.
i want to read element with "a" id but no "b" element in result?</p>
<pre><code><div id="a">
hi
<div id="b">
every one
</div>
<div>bye</div>
</div>
</code></pre>
<p>and result should be</p>
<pre><code> hi <div>bye</div>
</code></pre>
<p>how to do this?</p>
| jquery | [5] |
1,829,424 | 1,829,425 | Quickest way to get the value of a date with a custom label? | <p>In Contacts I have set up a Date field with a custom label (when editing a contact you select Add Field-> Date -> Anniversary -> Add Custom Label).</p>
<p>This is stored in the ABMultiValue property of ID 'kABPersonDateProperty' with a label of (for example) 'Next Appointment'.</p>
<p>The ABMultiValue API has functions to tell me the label name at an index, read the value at an index and convert between ID/Index.</p>
<p>Please forgive me if I am being thick here but is the quickest way to get the date of the 'Next Appointment' to iterate the Multivalue field looking for the index of a matching label then copy the value of the property at that index? From what I can tell, the index will vary from record to record.</p>
<p>I realise there is a function to get an index from a property ID, but that means that at some point earlier I will have to have discovered the propertyID by going through all the records trying to find one with the 'Next Appointment' field in it to get its propertyid.</p>
<p>I want to view the date in a tableview and sort on it so I need to get the value as efficiently as possible. Has anyone got a method of doing this quickly, preferably with example code or a link for further info?</p>
| iphone | [8] |
1,717,653 | 1,717,654 | php preg_replace problem | <pre><code>$strSubject= preg_replace('/\b'.$strWord.'\b/i', '<b>'.$strWord.'</b>', $strSubject);
</code></pre>
<p>above code works in php 5.2.6 but not working in php 5.2.9 and get " warning,unknow modifer....." error. please help</p>
| php | [2] |
2,067,699 | 2,067,700 | c# how to calculate the working days left in a month | <p>Hi i am new to <code>c#</code> and programing in general i have been trying to learn from adapting other peoples code the code below i have changed the code as i want to calulate the amount of working days left in a month but the problem is the code runs over the amount of days in a month so this month has <strong>29 days</strong> but the code errors as the code runs to the <strong>30th</strong> I can not figure out which part of the code to change any help would be great </p>
<pre><code> private void days()
{
//Monday to Friday are business days.
var weekends = new DayOfWeek[] { DayOfWeek.Saturday, DayOfWeek.Sunday };
DateTime testing = DateTime.Now;
string month1 = testing.ToString("M ");
string year1 = testing.ToString("yyyy");
int month = Convert.ToInt32(month1);
int year = Convert.ToInt32(year1);
//Fetch the amount of days in your given month.
int daysInMonth = DateTime.DaysInMonth(year, month);
string daysleft = testing.ToString("d ");
int daystoday = Convert.ToInt32(daysleft);
//Here we create an enumerable from 1 to daysInMonth,
//and ask whether the DateTime object we create belongs to a weekend day,
//if it doesn't, add it to our IEnumerable<int> collection of days.
IEnumerable<int> businessDaysInMonth = Enumerable.Range(daystoday, daysInMonth)
.Where(d => !weekends.Contains(new DateTime(year, month, d).DayOfWeek));
//Pretty smooth.
int count = 0;
foreach (var day in businessDaysInMonth)
{
count = count + 1;
}
textBox9.Text = count.ToString();
}
}
</code></pre>
| c# | [0] |
953,146 | 953,147 | Deactivate/activate link with jQuery? | <p>I'm looking for a simple solution to deactivate/activte button links. I could use addClass/removeClass to change the color to gray when deactivated, but there is still possible to click on the link. Is there a way to handle this?</p>
| jquery | [5] |
5,036,096 | 5,036,097 | Substract first sentence of the text and echo it, then echo the remaining text | <pre><code>$content = 'this is a small text';
$content = preg_replace('/\s+?(\S+)?$/', '', substr($content, 0, 100)); // i substract the first 100 chars from the text - only whole words
echo $content;
</code></pre>
<p>Is there a way to substract the first sentence in the text and echo it? Lets say untill the text reachers a "." or a "?" or a "!" ?</p>
<p>And then echo the remaining part of the text?</p>
<p>Thank you</p>
| php | [2] |
4,017,378 | 4,017,379 | java.lang.RuntimeException: Unable to start activity ComponentInfo{com.test.cal/com.test.cal.CalculatorActivity}: java.lang.NullPointerException | <p>Hi. I tried to create a calculator app for Android. Tried to code to show two buttons such that clicking on one of them displays it in a text box.</p>
<p>The code is:</p>
<pre><code>package com.test.cal;
android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class CalculatorActivity extends Activity implements OnClickListener {
EditText ans;
Button b1,b2;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
ans = (EditText) findViewById(R.id.ans);
b1=(Button) findViewById(R.id.one);
b2=(Button) findViewById(R.id.two);
b1.setOnClickListener(this);
b2.setOnClickListener(this);
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
public void onClick(View arg0) {
// TODO Auto-generated method stub
switch(arg0.getId())
{
case R.id.one:
ans.setText(1);
break;
case R.id.two:
ans.setText(2);
break;
default:Toast.makeText(this, "fuckoff", 1000);
break;
}
}
}
</code></pre>
<p>Clicking on the null point exception goes to the:</p>
<pre><code>b2=(Button) findViewById(R.id.two);
</code></pre>
<p>line. Please help. I am a beginner. Searched stack overflow, but didn't understand the few answers related to it.</p>
| android | [4] |
2,658,128 | 2,658,129 | Javascript - Adding variable to a string of code | <p>I realized how bad I am with javascript :(</p>
<p>I have this:</p>
<pre><code>function getUrlVars() {
var vars = {};
var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi,
function(m,key,value) {
vars[key] = value;
});
return vars;
}
var theidis = getUrlVars()["id"];
</code></pre>
<p>and</p>
<pre><code>$.tzPOST = function(action,data,callback){
$.post('php/ajax.php?id='+theidis,'&action='+action,data,callback,'json');
}
$.tzGET = function(action,data,callback){
$.get('php/ajax.php?id='+theidis,'&action='+action,data,callback,'json');
}
</code></pre>
<p>The first gets the ?id=value parameter properly. I tested with an alert(theidis).</p>
<p>I am looking to do a simple thing - sorry if this is stupid -.- I have worked as this for so long that I am beginning to oversee things.</p>
<p>I want an ?id=value to be added to the php/ajax.php. I tried with the above, but it doesn't seem to work. I also tried by just adding it.</p>
<p>Thank you in advance. :-)</p>
| javascript | [3] |
4,956,339 | 4,956,340 | Horizontal black lines appearing on background images | <p>Horizontal black lines appearing on background images.
This issue observed randomly on Samsung sky rocket device.</p>
<p><img src="http://i.stack.imgur.com/9CYze.png" alt="this is a background image used for TabActivity "></p>
<p>Till now there was no issue with images but suddenly it start appearing randomly on Sky rocket.</p>
| android | [4] |
3,451,404 | 3,451,405 | Simple question on a PHP variable to change and localize the output | <p>how can I change the output of the following to something like <code>2 hours and 30 minutes</code>? </p>
<p>The current output is <code>'hours':02,'mins':30</code></p>
<p>Also how can I change hours to my language? (greek)</p>
<pre><code>function time_difference($endtime){
$times=array(
'hours' => date("G",$endtime),
'mins' => date("i",$endtime),
);
//added a "just a moment ago" feature for you
if (intval($times['hours'], 10) == 0
&& intval($times['mins'], 10) == 0) {
return "just a moment ago";
}
$diff='';
foreach ($times as $k=>$v) {
$diff.=empty($diff) ? '' : ',';
$diff.=intval($v, 10) == 0 ? '' : "'$k':$v";
}
return $diff;
}
</code></pre>
| php | [2] |
1,045,171 | 1,045,172 | Using an "if" statement when there is no arg | <p>Im supposed to be giving the program two arguments: one for current speed in mph and the other, the speed limit in kph. My program must use the converter file to change your current speed to kph so as to be compared to the speed limit then warn the user via Dashboard display that they are speeding. But if only one arg is given, the program must use 40kph as the default speed limit. My problem lies in not knowing how to code an IF statement for a lack of args. Help!?!</p>
<pre><code>public class DetailedSpeedSetter
</code></pre>
<p>{</p>
<pre><code>public static void main(String args[])
{
double kph;
double mph;
double SpeedLimit;
mph = Text.toNonnegativeDouble(args [0]);
kph = Converter.toKPH(mph);
SpeedLimit = Text.toNonnegativeDouble(args[1]);
/**
* Determines whether the given speed exceeds the given limit
*
* @param speed The speed in km/hr
* @param limit The speed limit in km/hr
* @return true if speed exceeds limit and false otherwise
*/
public static boolean isSpeeding(double speed, double limit)
{
speed = kph;
limit = SpeedLimit;
if (speed > limit);
return true;
if (speed <= limit);
return false;
}
Dashboard.setSpeed(kph);
Dashboard.setSpeeding();
}
}
</code></pre>
| java | [1] |
3,090,287 | 3,090,288 | Keep getting missing ";" before "." errors | <p>I have the header specification for a class here:</p>
<pre><code>#ifndef FIXEDWINGAIRCRAFT_H
#define FIXEDWINGAIRCRAFT_H
#include <iostream>
class FixedWingAircraft
{
private:
struct Airframe
{
double weight;
};
struct Engine
{
double weight;
double fuel;
};
struct Radio
{
bool state;
double weight;
};
struct Pilot
{
int proficiency;
double weight;
};
public:
void setAirframe(double w)
{
Airframe.weight = w;
}
void setEngine(double w, double f)
{
Engine.weight = w;
Engine.fuel = f;
}
void setRadio(bool s, double w)
{
Radio.state = s;
Radio.weight = w;
}
void setPilot(int p, double w)
{
Pilot.proficiency = p;
Pilot.weight = w;
}
};
#endif
</code></pre>
<p>But when I try to compile, I get tons of syntax errors saying:</p>
<pre><code>error C2143: syntax error : missing ';' before '.'
</code></pre>
<p>I'm assuming these refer to the setter functions, but I don't see why that should be causing an issue. What am i missing?</p>
| c++ | [6] |
4,833,646 | 4,833,647 | String.split(".") is not splitting my long String | <p>I'm doing the following:</p>
<pre><code>String test = "this is a. example";
String[] test2 = test.split(".");
</code></pre>
<p>the problem: <code>test2</code> has no items. But there are many <code>.</code> in the <code>test</code> <code>String</code>.</p>
<p>Any idea what the problem is?</p>
| java | [1] |
5,021,192 | 5,021,193 | how to make rounded corners for image in android ? | <p>how to make a rounder corners for image view in android ??</p>
| android | [4] |
6,004,490 | 6,004,491 | Why can't I initialize my static data member in my constructor | <p>I read the answer in parashift but i need bit details as to why compiler wont allow to define static member variable in constructor.</p>
<p>Answer will be highly appreciated.</p>
<p>Thanks.</p>
| c++ | [6] |
4,636,289 | 4,636,290 | Get ID of the element I hover over with jQuery? | <p>I have a bunch of elements that look like this:</p>
<pre><code><span class='tags' id='html'>html</span>
<span class='tags' id='php'>php</span>
<span class='tags' id='sql'>sql</span>
</code></pre>
<p>How would I get the name of the id of the one I hover over, so I could output something like "You're hovering over the <strong>html</strong> tag". (What I want to do isn't that arbitrary, but I do need to get the name of the tag the user hovers over in order to do it.)</p>
| jquery | [5] |
2,487,563 | 2,487,564 | Hurdle with inheritance in Java | <p>I dont understand the program below. I have mentioned the two errors I have encountered in the code. But I cannot understand the reason</p>
<pre><code>import java.io.*;
class sdata
{
float per;
int m,tm=0,i,n;
sdata(int n)throws Exception
{
DataInputStream dis2=new DataInputStream(System.in);
for(i=1;i<=n;i++)
{
System.out.print("enter marks of subject"+i);
int m=Integer.parseInt(dis2.readLine());
tm=tm+m;
}
per=tm/n;
}
}
class disdata extends sdata
{
//below line gives an error "constructor sdata in class xyz.sdata cannot be applied to given types required:int found:no arguments"
disdata() throws Exception{
System.out.println("TOTAL MARKS OF SUBJECTS:"+tm);
System.out.println("PERCENTAGE OF STUDENT:"+per);
}
}
class sresult
{
public static void main(String args[])throws Exception
{
DataInputStream dis=new DataInputStream(System.in);
int n=Integer.parseInt(dis.readLine());
disdata objj=new disdata();
//the below line creates an error saying "cannot find symbol"
objj.sdata(n);
}
}
</code></pre>
| java | [1] |
4,658,029 | 4,658,030 | Checking Run Time / Compile Time in a widget? | <p>I have a custom widget and want to check in it: whether we are in compile time or run time?
My widget does some process in run time, but i want to show a simple text in XML layout preview in compile time.
Is there any way for this?</p>
| android | [4] |
4,195,907 | 4,195,908 | Unexpected output in javascript | <p>I am beginner to javascript and i am getting unexpected output</p>
<p>here is the code</p>
<pre><code><script type="text/javascript">
function add(a,b)
{
x = a+b;
return x;
}
var num1 = prompt("what is your no.");
var num2 = prompt("what is another no.")
alert(add(num1,num2));
</script>
</code></pre>
<p>it should give output as a sum of two number entered by us on prompting but it is simply concatenating the two number and popping the output</p>
| javascript | [3] |
4,535,525 | 4,535,526 | Delete the file manually for day to day process | <p>I've created a log file for day to day processing and i want to delete the old files generated before 2 days.</p>
| php | [2] |
2,943,014 | 2,943,015 | Change style of text field based on the selection of a combo box using Javascript | <p>I would like to change the style of a text field based on the value selected in a combo box. Specifically, what I'd like to do is make the txtDepartment field gray and marked as "read only" if the option value selected in cboSource is 1. I've tried the code below, but I imagine my style code at least is wrong, if not other things. Any help appreciated. Thanks!</p>
<pre><code><select name="cboSource" id="cboSource" onClick="displayDepartment(this);">
<option value = 1>Source 1</option>
<option value = 2>Source 2</option>
</select>
<input name="txtDepartment" type="text" id="txtDepartment" size="6" maxlength="6"></p>
<script>
function displayDepartment(obj)
{
var selectedValue = obj.value;
var txtDepartment = document.getElementById("txtDepartment");
if (selectedValue == "1")
{
txtDepartment.style.display = "Disabled style='background-color:#E8E8E8'";
}
}
</script>
</code></pre>
| javascript | [3] |
3,346,484 | 3,346,485 | How to add submit event to dynamically generated form? | <p>Here is the PHP code that generates the form:
form.php </p>
<pre><code> <?php
echo '
<form action="/wall/comment.php" method="post" id="submit-comment-form" name="'.$postid.'">
<div class="write-comment-profile-pic">
<img src= "'.$myprofilepic.'" width="30" height="30""/>
</div>
<div class="write-comment-textbox-wrap">
<input type="text" class="textbox4" id="write-comment-textbox" value="Write a comment..." name="comment" style="width:65%;" />
</div>
</form>
';
?>
</code></pre>
<p>Jquery code which gets the form.php</p>
<pre><code>$('#images img').click(function() {
$.get('form.php', function(data) {
$('#image-pop-up').html(data);
});
});
</code></pre>
<p>AND here is the jquery code to needs to submit the form:</p>
<pre><code>$('#image-pop-up').on('submit', '#submit-comment-form', function() {
evt.preventDefault();
});
</code></pre>
<p>in index.html image-pop-up div is an empty one
just </p>
<p><code><div id="image-pop-up"></code></p>
<pre><code></div>
</code></pre>
<p>this isn't working... what's wrong? how to fix it?</p>
| jquery | [5] |
2,525,513 | 2,525,514 | Clear an Array to NULL without knowing the type | <p>I have to create a function that can take in an array of pointers with a known size, and set all the pointers to NULL. The caveat is that I don't know the type beforehand. This is what I have tried so far:</p>
<pre><code> template <typename T>
static void Nullify(T** _Array, int _Size, unsigned int _SizeOf)
{
for (int i = 0; i < _Size; i++)
{
_Array[i * _SizeOf] = NULL;
}
}
</code></pre>
<p>Which is giving me errors (not the function itself, but I am trampling on memory I should not be trampling on resulting in a memory error later on). I am passing in the array (_Array - already initialized to _Size), its size (_Size), and the sizeof(Pointer*) as _SizeOf.</p>
<p>Any help would be greatly appreciated :) </p>
| c++ | [6] |
4,123,920 | 4,123,921 | Replacing image source in HTML image tag, and excludes certain images | <p>I have the following code</p>
<pre><code>$body = preg_replace('/<img(.*?)src="(.+)"/Ui','<img src="renderImage.php?image=\\2&width=<?=$img_width?>&url=<?=$mobiURL?>"',$body);
</code></pre>
<p>$body contains a whole html page that contains img tags, the above code works perfectly, but I need to exclude images with the string maps.google in it so that it does not get replaced.</p>
<p>Is there any way to do this</p>
| php | [2] |
5,813,523 | 5,813,524 | I have a certain script for Feed back. | <p>I have a certain script for Feed back. when i submit the form, it shows</p>
<p>"
Warning: substr() expects parameter 2 to be long, string given in /home/jetkvdmn/public_html/genFunctions.php on line 26"</p>
<p>the code below</p>
<pre><code><?php
$cEpro ="&copy; Redeeming Mission 2012.";
function checkText($ElementVal) {
// If Text is too short
if (strlen($ElementVal)< 3) {
//alert('Text too small');
return false;
} else{
return true;
}
}
function checkEmail($vEmail) {
$invalidChars ="/:,;" ;
if(strlen($vEmail)<1) return false; // Invalid Characters
$atPos = stripos($vEmail,"@",1); // First Position of @
if ($atPos != false)
$periodPos = stripos($vEmail,".", $atPos); //If @ is not Found Null . position
for ($i=0; $i<strlen($invalidChars); $i++) { //Check for bad characters
$badChar = substr($invalidChars,i,1); //Pick 1
if(stripos($vEmail,$badChar,0) != false) //If Found
return false;
}
if ($atPos == false) //If @ is not found
return false;
if ($periodPos == "") //If . is Null
return false;
if (stripos($vEmail,"@@")!=false) //If @@ is found
return false;
if (stripos($vEmail,"@.") != false) //@.is found
return false;
if (stripos($vEmail,".@") != false) //.@ is found
return false;
return true;
}
?>
</code></pre>
| php | [2] |
3,599,049 | 3,599,050 | Local notification fire date back up | <p>I am developing an application in which i have implemented the local notifications concept. It is working fine. Let suppose I have set 5 notifications at different times. When first two notifications has been happened. But i didn't check it. Now when third notification rings, i viewed it. Now Is it possible to get the date time when first two alarms had. I need the date time for those notifications which the user has not seen.</p>
| iphone | [8] |
2,071,923 | 2,071,924 | How to combine all the resources of a program? | <p>Is there a way to make c# programs a single, executable, file that people can just download and play, instead of installing?</p>
| c# | [0] |
2,846,019 | 2,846,020 | ASP.NET program fine for 30 mins then crashes | <p>My ASP.NET program works fine for 30 mins (approx) then crashes with the generic status code 500. I've reviewed my code and can't seem to figure out what the problem could be. The program is running under II6 and I'm using .Net 2.0. Could this be an application pool issue?</p>
<p>Thanks</p>
| asp.net | [9] |
977,498 | 977,499 | Check for duplicate before adding into array, using pointers | <p>I have a global static Strings str[MAX] = { "aloha" , "behold", "donkey", "key", "joke", "none", "quack", "orange"};</p>
<p>The size here was randomly generated, for example if size = 3, it will print out "Behold", "donkey" and "none". Before adding into the array, i want to check if it is inside.
if "Behold", "donkey", "none" is inside the array, and if i get another word, "donkey", it will reject and go back to loop and generate another one, thus i use i--</p>
<p>I'm not sure where went wrong, i hope someone can enlighten me.</p>
<p>Thanks. Here's the code.</p>
<pre><code>typedef char* Strings;
function example (Strings *s, int size)
{
char *q;
bool check;
q = new char[MAX];
*s = &q[0];
for (int i = 0; i < size; i++)
{
k = rand () % 8;
if (*s == '\0')
*s = Str[k];
else
{
check = compare (s, Str[k]);
if (check == 1)
*s = Str[k];
else
i--;
}
++s;
}
cout << endl;
}
bool compare (Strings *s, char *str)
{
while (*s != '\0')
{
if (strcmp (*s, Str))
return true;
else
return false;
++s;
}
}
</code></pre>
| c++ | [6] |
2,689,141 | 2,689,142 | array_multisort to sort several arrays | <p>I've searched for this but can't seem to find the exact answer. I want to use array_multisort to simultanously sort 3 arrays based on numeric values in 3 of the arrays. Basically I want to make a "standings" table similar to what you'd see for NFL/NHL standings etc. I have 3 arrays, tempIDs (string), tempWins (numeric), tempWinPercentage (numeric). I need all 3 to be sorted at the same time based first on wins, and then if there is a tie, win percentage.</p>
<p>I can't seem to get array_multisort to work with more than just 2 arrays, so maybe I'm misunderstanding the terminology when they say that it can work with "several" arrays. Thank you!</p>
| php | [2] |
2,469,260 | 2,469,261 | Javascript calculation from html input id always results in 1 | <p>I'm running into an error when performing a calculation on submit using javascript. The pay_amount input submits '1' and total_charged submits '4.95' regardless of what the value of pay_amount is.</p>
<p>Here is the html:</p>
<pre><code><form method="POST" action="example-post-url.php" autocomplete="off" name="form" id="form">
<input type="text" id="pay_amount" name="pay_amount" value="1,794.00"/>
<input type="hidden" id="total_charged" name="total_charged" />
<input type="submit" value="submit" onclick="submitCard();" id="submitButton"/>
</form>
</code></pre>
<p>Here is the javascript:</p>
<pre><code><script>
function submitCard(){
var payment = parseFloat(document.getElementById('pay_amount').value);
var fee = ((payment*0.035)+3.95);
var total = payment + fee;
document.getElementById('total_charged').value = total.toFixed(2);
document.form.submit();
}
</script>
</code></pre>
<p>I've tried replacing var payment with the code below thinking it was an issue with commas, but I'm still running into problems.</p>
<pre><code>var payment = document.getElementById('pay_amount').value.replace(/,/g, '');
</code></pre>
<p>What in the world is going on here?</p>
| javascript | [3] |
2,600,070 | 2,600,071 | Assigning variable or array to object element in javascript | <p>I've got something like this which works, but I want to use the <code>result2</code> array for the first series<code>.data</code> rather than hardcoding. Using <code>data: result2</code> or <code>data: [result2]</code> does not work. Is it not possible to assign with a variable in this kind of declaration?</p>
<pre><code>var chart1;
$(document).ready(function() {
$.get('sales_data', function(result) {
var result2 = result.split(',');
chart1 = new Highcharts.Chart({
series: [{
type: 'column',
name: 'Units',
data: [1, 3, 4]
}, {
type: 'line',
name: '3 month avg',
data: [2, 3, 4]
}]
});
});
});
</code></pre>
| javascript | [3] |
1,784,171 | 1,784,172 | how to display MJPEG over the android | <p>I want to display MJPEG (generated by live camera) in the Android device. is this possible to display MJPEG over the android device. if yes then how I will implement it.</p>
| android | [4] |
4,035,141 | 4,035,142 | Android, trying to enlarge text if it's on a bigger screen | <p>I am trying to enlarge the size of text in a button as the screen gets wider. At first it seemed my code worked, but on different android devices it does not work. It will change the font to a big size on a small screen. </p>
<p>This is what I'm doing:</p>
<pre><code> int w=getWindowManager().getDefaultDisplay().getWidth();
Button but1=new Button(this);
// but1.setTextColor( Color.parseColor("#ffd79825"));
if (w<400)
but1.setTextSize(10.0f);
else
if (w<650)
but1.setTextSize(14.0f);
else
if (w>470)
but1.setTextSize(18.0f);
</code></pre>
| android | [4] |
1,283,951 | 1,283,952 | Convert Datagrid or Gridview to excel with Page break | <p>I need to convert either an ASP.NET Datagrid or GridView to excel with a page-break that can be part of the target excel.
The first part to convert the grid control to excel is not that complex and fairly easy to do, but my problem is how to insert a page break to the excel file during the conversion process.
Thanks for the help.</p>
| asp.net | [9] |
3,229,863 | 3,229,864 | PHP, How can I retrieve a specific number? | <p>I need to retrieve itunes app id from the URL address.</p>
<p><a href="https://itunes.apple.com/us/app/angry-birds-star-wars/id557137623?mt=8" rel="nofollow">https://itunes.apple.com/us/app/angry-birds-star-wars/id557137623?mt=8</a></p>
<p>I used strpos(), but this one didn't work.</p>
<p>How can I get numbers after id from this address?</p>
<p>$url = 'https://itunes.apple.com/us/app/angry-birds-star-wars/id557137623?mt=8';</p>
<p>$result = '557137623'</p>
<p>result will be like this one. </p>
| php | [2] |
4,475,171 | 4,475,172 | Take the Binary From Text Area and then Converting to Hexa | <p>I want to take a binary in the text area and convert it to hex. When calculated using the calculator, result is "E0AC882AA428B6B8", but with my code result is "30". </p>
<pre><code>String str = txtXOR.getText();
char[] chars = str.toCharArray();
StringBuffer hex = new StringBuffer();
int x = chars.length;
for(int i = 0; i < x; i++){
hex.append(Integer.toHexString((int)chars[i]));
txtXORToHexa.setText(Integer.toHexString((int) chars[i]));
}
</code></pre>
<p>Could someone point out where I have gone wrong?</p>
| java | [1] |
3,345,542 | 3,345,543 | JSON POST data interpreted differently between IE and FF | <p>I am using valum's fileuploader <a href="http://valums.com/ajax-upload/" rel="nofollow">http://valums.com/ajax-upload/</a> to upload a file. Upon complete (i.e. onComplete: function(id, fileName, responseJSON){}), I get the following POST response as viewed by Firebug.</p>
<pre><code>{"id":"13","filename":"Brighton\u2019s Rock Collection.docx","size":"12 KB","date":"07\/18\/2012","time":"09:34:35 AM","icon":"<img src=\"lib\/stdimages\/icons\/32x32\/doc.png\" width=\"32\" height=\"32\" \/>","errors":[]}
</code></pre>
<p>Next, I want to append a row to a table with the new data. Works great with Firefox, but when IE8 is used, the icon's don't show up. I don't know a good way to troubleshoot IE, so I just do alert(responseJSON.icon);. Instead of what I expect, I get: </p>
<pre><code><IMG src='"lib/stdimages/icons/32x32/doc.png"' width='"32"' height='"32"' />
</code></pre>
<p>The img was changed to IMG and I get single quotes around my attributes. Well, that is probably why the icons are not showing up. Can anyone tell me why this is happening, and what I need to do to prevent it.</p>
<p>Thank you</p>
| javascript | [3] |
3,348,720 | 3,348,721 | getElementByTagName not working? | <p>In the code below, I am applying a different background color to all even rows by dynamically assigning the class "even" to them using javascript. I am calling the alternamte() function onload of the body tag. </p>
<p>At first, I was using getElementById to get the table object and my code worked fine. However, I am suppose to apply this styling to ALL tables on my page, so I need to use get element by tag name.</p>
<p>Once I made the chane to getElementByTagName, my code stopped working and I have been trying to find out the root of the problem for a while now with no success. I was wondering if someone can help me understand why my code stopped working after I made the change to getElementByTagName?</p>
<pre><code> <script type="text/javascript">
function alternate(){
var table = document.getElementsByTagName("table");
var rows = table.getElementsByTagName("tr");
for(i = 0; i < rows.length; i++){
//change style of even rows
//(odd integer values, since we're counting from zero)
if(i % 2 == 0){
rows[i].className = "even";
}
}
}
</script>
</code></pre>
| javascript | [3] |
4,124,893 | 4,124,894 | C# object and string conversion | <p>I have following section of code in my program:</p>
<pre><code> object val;
val = arr[1].Trim(); // in my case i am getting value here is 1.00
</code></pre>
<p>now when I am assigning value to a datarow I am getting error </p>
<blockquote>
<p>Expected int64 value.</p>
</blockquote>
<pre><code>datarow[Convert.ToString(drow["col"]).Trim().ToUpper()] = val;
</code></pre>
<p>I am not facing any issue when getting value other that 1.00.</p>
<p>What could be the exact problem? How can I solve it?</p>
<p>Suggestions and solutions are welcome</p>
| c# | [0] |
3,407,724 | 3,407,725 | int* pointer vs. int *pointer for pointer declaration | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/558474/what-makes-more-sense-char-string-or-char-string">What makes more sense - char* string or char *string?</a> </p>
</blockquote>
<p>The syntax for pointers has never made sense to me. I noticed that both of these options work for declaring a pointer. Which one should I be using?</p>
| c++ | [6] |
2,175,532 | 2,175,533 | how to make a ratingbar with real time update in android? | <p>Android doc <a href="http://developer.android.com/reference/android/widget/RatingBar.OnRatingBarChangeListener.html" rel="nofollow">said</a> </p>
<blockquote>
<p>public abstract void onRatingChanged (RatingBar ratingBar, float
rating, boolean fromUser)</p>
<p>Since: API Level 1 Notification that the rating has changed. Clients
can use the fromUser parameter to distinguish user-initiated changes
from those that occurred programmatically. This will not be called
continuously while the user is dragging, only when the user finalizes
a rating by lifting the touch.</p>
</blockquote>
<p>How can I build an ratingbar that can update as user dragging through it?</p>
<p>I also find ratingBar is not very customziable. The way to change image is some what hack as mentioned <a href="http://stackoverflow.com/questions/607610/how-to-change-the-star-images-of-the-ratingbar">here</a>
Are there any open sourced ones?
Thanks </p>
| android | [4] |
933,470 | 933,471 | I want to reject in-coming call for a particular number but it does not work | <p>I am trying to block incoming call for a particular number. first I try for all incoming call.
it works well.
but when I try for a particular number by the following code the call is not rejected and the phone is ringing ,I tried with my android phone..</p>
<pre><code> @Override
public void onReceive(Context context, Intent intent) {
Log.v(TAG, "Receving....");
String t1="01741297163",t2="08801741297163";
TelephonyManager telephony = (TelephonyManager)
context.getSystemService(Context.TELEPHONY_SERVICE);
try {
Class c = Class.forName(telephony.getClass().getName());
Method m = c.getDeclaredMethod("getITelephony");
m.setAccessible(true);
Bundle b=intent.getExtras();
num=b.getString(telephony.EXTRA_INCOMING_NUMBER);
if(num.equals(t1)||num.equals(t2)){
telephonyService = (ITelephony) m.invoke(telephony);
//telephonyService.silenceRinger();
telephonyService.endCall();
} }catch (Exception e) {
e.printStackTrace();
}
</code></pre>
<p>I do not know the format of incoming number get from the Telephonymanager. </p>
| android | [4] |
2,607,302 | 2,607,303 | What is android:ems attribute in Edit Text? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/7053738/what-means-ems-android-textview">What means Ems? (Android TextView)</a> </p>
</blockquote>
<p>In <code>EditText</code> there is an attribute named <code>android:ems</code>. The description
is "Makes the <code>EditText</code> be exactly this many ems wide"</p>
<p>What does ems mean? </p>
| android | [4] |
344,942 | 344,943 | User is unable to enter the value of the string variable | <p>User is unable to enter the value of the string variable.</p>
<p>This is the program: </p>
<pre><code>import java.io.*;
public class testing
{
char a;
int b;
double c;
String d;
public void method() throws IOException
{
BufferedReader p=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter a variable of type 'char'");
a = (char)p.read();
System.out.println("Enter a variable of type 'string'");
d = p.readLine();
System.out.println("Enter a variable of type 'integer'");
b = Integer.parseInt(p.readLine());
System.out.println("Enter a variable of type 'double'");
c = Double.parseDouble(p.readLine());
System.out.println("Your values are: string-" +d +", integer-" +b +", double-" +c);
}
}
</code></pre>
<p>Can someone see a problem?</p>
| java | [1] |
4,292,604 | 4,292,605 | Prepend the same string to all items in a list | <p>Have done some searching through Stack Exchange answered questions but have been unable to find what I am looking for.</p>
<p>Given the following list:</p>
<pre><code>a = [1, 2, 3, 4]
</code></pre>
<p>How would I create:</p>
<pre><code>a = ['hello1', 'hello2', 'hello3', 'hello4']
</code></pre>
<p>Thanks!</p>
| python | [7] |
3,151,087 | 3,151,088 | Scripts don't work in ajax content | <p>My script to load dynamic content is this and works perfectly, the problem is that i cannot include scripts to the dynamic content. :</p>
<p>$('nav li a').click(function(){ </p>
<pre><code> $(this).addClass("green");
$('nav a').not(this).removeClass("green");
var toLoad = $(this).attr('href')+' #content';
$('#content').hide('fast',loadContent);
$('#load').remove();
$('#main').append('<span id="load">LOADING...</span>');
$('#load').fadeIn('normal');
window.location.hash = $(this).attr('href').substr(0,$(this).attr('href').length-5);
function loadContent() {
$('#content').load(toLoad,'',showNewContent());
}
function showNewContent() {
$('#content').show('slow',hideLoader());
}
function hideLoader() {
$('#load').fadeOut('normal');
}
return false;
// this is the script that i want to trigger
$('.lightbox').lightBox();
});
</code></pre>
<p>This way doesn't work, i also try the delegate mode like this:</p>
<pre><code>$('#content').delegate('img', 'click', light);
var light = $('.lightbox').lightBox();
</code></pre>
<p>Can anyone help me please?</p>
<p>Thanks in advance.</p>
| jquery | [5] |
2,249,297 | 2,249,298 | can I set default parameter value in construture? | <p>Can I set the default arument value in Construct function something like
?</p>
<pre><code>public class XLSReader {
public XLSReader(String filename="XYZ.xls") {
}
}
</code></pre>
| java | [1] |
3,719,630 | 3,719,631 | how to trim quotation marks on a variable? | <p>I'm new to php so please no bullying. I have the following and I can't trim the quotation mrks around the name of my variable. For some reason the following displays "Workaholics", why ?
I'm using a library to scrape IMDB and all my titles come back with those quotation marks in my $movieArray.</p>
<p>Thanks.</p>
<pre><code> $movieArray["title"] = '"Workaholics"';
echo trim($movieArray["title"], '"');
</code></pre>
<p>So this works but it doesn't work below:</p>
<pre><code> $imdb = new Imdb();
$movieArray = $imdb->getMovieInfo("Workaholics");
{
echo trim($movieArray["title"], '"');
echo $movieArray["poster"];
}
</code></pre>
<p>Where $movieArray["poster"] = '"Workaholics"'... That doesn't work, trim doesn't work either.</p>
<p>Output: </p>
<pre><code>"Workaholics"
</code></pre>
| php | [2] |
39,035 | 39,036 | how to create a custom datatype in java? | <p>I want to create an custom datatype in Java,for example datatype Email , that having following method isValidate(String email),isEmailExist(String email),getDomain(String email), get Id(String email),just like Integer class in java.</p>
<p>Integer is a class and I can initialise the object of Integer class as follows:</p>
<p>Integer i = 100;</p>
<p>I created my class Email and I want to initialise it as follows
Email e = "sam";</p>
<p>How can i perform this functionality in my Email class.<pre>import java.util.StringTokenizer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;</p>
<p>public class Email
{
private String email;
public Email(String email)
{
this.email=email;
}</p>
<pre><code>Email() {
}
public Boolean isvalid(String email)
{
</code></pre>
<p>String lastToken = null;
Pattern p = Pattern.compile(".+@.+\.[a-z]+");
// Match the given string with the pattern
Matcher m = p.matcher(email);
// check whether match is found
boolean matchFound = m.matches();
StringTokenizer st = new StringTokenizer(email, ".");
while (st.hasMoreTokens())
{
lastToken = st.nextToken();
}</p>
<p>if (matchFound && lastToken.length() >= 2
&& email.length() - 1 != lastToken.length())
{</p>
<pre><code> return true;
</code></pre>
<p>}
else
return false;</p>
<pre><code>}
</code></pre>
<p>public String toString() {
return email;
}</p>
<p>}</p>
<p></pre></p>
<p>Thanks</p>
| java | [1] |
5,764,842 | 5,764,843 | Why does g++ link the standard library? | <p>I have a simple piece of c++ code:</p>
<pre><code>#include <iostream>
using namespace std;
int main ()
{
cout << "Hello World!";
return 0;
}
</code></pre>
<p>When I generate the assembly of this code I get a huge assembly file which I presume is compilation of the standard library. Why does this happen and how can I prevent it?</p>
| c++ | [6] |
1,034,530 | 1,034,531 | Automatically concat several JavaScript files in one? | <p>I have many js files, with some naming convention. If there any tool that concatenate all this files in one, so I don't need to include them all separately ?</p>
| javascript | [3] |
761,968 | 761,969 | prevent DropDownList from going to the original value when refreshing the page | <p>I have a DropDownList on an ASP.NET master page and I want to change some values and refresh the page when I select a different item from the list. I enabled the post back property in the DropDownList but it still gets back always to the first value whenever I select. Any advice?</p>
| asp.net | [9] |
5,374,381 | 5,374,382 | remove a class from a tag and add it to another | <p>i have following html i cannot edit the html:</p>
<pre><code><tr>
<td>
<font class="text colors_text"><span class="percarton" style="font-weight: normal;"><font class="text colors_text">
<b>Price Per Carton </b></font></span><span class="csqft_price">$101.82</span></font><br>
<b> <span class="percarton" style="font-weight: normal;">Members Price 1: </span>
<span class="csqft_price"><font class="pricecolor colors_productprice">$96.82<br>
</font></span></b>
</td>
</tr>
</code></pre>
<p>Whenever there is members price in html then <code><span class="csqft_price"></span></code> of the price per carton should get removed and it should get apllied to $96.82 also the <code><span class="csqft_price"></span></code> before the font tag should get removed . Please advise.</p>
| jquery | [5] |
1,597,175 | 1,597,176 | Using == when comparing objects | <p>Recently in a job interview I was asked this following question (for Java):</p>
<p>Given:</p>
<pre><code>String s1 = "abc";
String s2 = "abc";
</code></pre>
<p>What is the return value of </p>
<pre><code>(s1 == s2)
</code></pre>
<p>I answered with it would return false because they are two different objects and == is a memory address comparison rather than a value comparison, and that one would need to use .equals() to compare String objects. I was however told that although the .equals(0 methodology was right, the statement nonetheless returns true. I was wondering if someone could explain this to me as to why it is true but why we are still taught in school to use equals()?</p>
| java | [1] |
5,162,703 | 5,162,704 | Ensure whether request is made by Android Application? | <p>I have RESTful http api that my android application communicates with. Is there any way to ensure whether the request are made only from my application?</p>
| android | [4] |
4,900,369 | 4,900,370 | What is the best tool to convert WSDL to objective c client stub? | <p>Can anyone suggest me on which is best tool to convert a WSDL to objective c client stub for iPhone? I am aware of WSDL2OBJC and SUDC tool. Which is a best tool and gives memory leak free client stubs.</p>
<p>Thanks in advance.</p>
| iphone | [8] |
4,825,051 | 4,825,052 | jquery fadein addClass | <p>I am using jQuery to apply a class to an element on hover i.e. <code>addClass('active')</code></p>
<p>The class adds a border and changes the background color but i would like to have these changes faded in as opposed to just on or off.</p>
<p>Is this possible using jQuery i.e. to add a class and have the effects that the class adds to be faded in?</p>
| jquery | [5] |
5,766,678 | 5,766,679 | Converting date formats | <p>How can i convert a date of birth like 11/20/1978 to something like November 20, 1978 using PHP? </p>
<p>Thanks</p>
| php | [2] |
3,440,956 | 3,440,957 | Android hierarchical preferences | <p>I'm writing a web service client and have the three obvious settings: url, username and password. For this the key value pairs in <a href="http://developer.android.com/reference/android/content/SharedPreferences.html" rel="nofollow">SharedPreferences</a> would be enough. But I hit a roadblock when I wanted to subscribe to more than one server instance. What I need is the three settings stored once for each server instance added by the user. Whats the best approach here? Create a custom settings activity and save it to a <a href="http://developer.android.com/training/basics/data-storage/files.html" rel="nofollow">file</a>?</p>
| android | [4] |
464,638 | 464,639 | Static for loop? Performing calculations before | <p>I'm feeling lost as to how to do this. I am trying to perform a calculation with a value that needs to be a global variable. but to be global it has to be static. I need the for loop to be static too so it can perform the calculation in the array but I can't remember how to do this.
The very last line of code is where I am stuck currently due to "Cannot find symbol" errors. I am trying to find a way to bring yVal0 in to this method so I can perform the calculation</p>
<pre><code>import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class RegressionGUI extends JFrame
implements ActionListener {
private JLabel VariableLabel = new JLabel("Select one independent Variable");
</code></pre>
| java | [1] |
5,938,462 | 5,938,463 | whats the significance between having the java class containing the main method setup as public and not | <p>When I started learning Java I too started with the ubiqutous Hello world app. Which is more or less like :</p>
<pre><code>public class MyClass {
public static void main(String args[]){
//some code here....
}
}
</code></pre>
<p>Its been many years since my tryst with Java but recently I was confronted by a beginner with a problem : Her class file wouldn't run even though she was able to compile correctly.</p>
<p>After looking at her code the first thing I noticed was that is didn't have the public access specifier on the class with the main method. I immediately mocked her on that slip up and went about "fixing" it by adding the public access modifier. The joke was on me offcourse as that didn't make any difference either. I then realized that she was trying to execute the compiled class from a different directory from the one where the class file was. I changed to that dir and issued the java command and it ran immediately. </p>
<p>This brings me to my question... Most hello world examples have the class setup with public access when its just as ok to not have that at all. So what difference does it make if at all for a class that contains the main method ? </p>
<p>To help make it clearer as to what we were doing exactly here are the steps :</p>
<p>We had the class in </p>
<pre><code>c:\users\[usersname]\[my documents folder]\myprog.class
</code></pre>
<p>and we tried to run it from c:\ (as our working dir) . We did specify the full relative path expecting it to work. like so :</p>
<pre><code>java users\[usersname]\[my documents folder]\myprog
</code></pre>
<p>Offcourse this just failed untill I changed into the documents folder making it the current working dir and issuing the command again like so</p>
<pre><code>java myprog
</code></pre>
<p>So basically such a call makes sense when you have the class in a package resembling the folder structure prepended to its name. In this case the class is not in any package.</p>
| java | [1] |
3,007,103 | 3,007,104 | add the image for each listview item in out of the listview | <p>Hi i want to add the particular image for each listView item left side .but that is not included in the listview ,see the image from below link
<a href="http://i51.tinypic.com/6ntwdh.png" rel="nofollow">Image</a></p>
| android | [4] |
5,825,024 | 5,825,025 | How do I extract the digits of a number in C++? | <p>Basically I would like to make a small little program that when u enter a number (say 145) it read the 3 digits and prints the largest one. </p>
<p>int a, b, c, max;</p>
<pre><code>cout << "Enter a, b and c: ";
cin >> a >> b >> c;
max = a;
if (b>max)
max = b;
if (c>max)
max = c;
cout << "Max is " << max << "\n";
</code></pre>
<p>I was think of using something like this, but I have no idea how to get the computer to read each individual digit.
thanks!</p>
| c++ | [6] |
4,991,786 | 4,991,787 | Android: How to use Google speech recognition in Chinese? | <p>When using Google Translate, you can switch to Chinese speech recognition,but how can I to implement Google Chinese speech engine in a Android phone?</p>
<p>Right now, I can use default Google English speech engine, is there possible I can choose the different language, such as English, Japanese, Spanish, French etc...</p>
| android | [4] |
1,090,927 | 1,090,928 | delete an object of an array without looping all the array | <p>I want to be able to delete an object from an array without looping all the array of objects to see if the current array element has the ID of the item I want to delete.</p>
<p>javascript:</p>
<pre><code>function CBooks() {
this.BooksArray = [];
this.AddBook = function(divID, sContents) {
this.BooksArray.push(new CBook());
pos = this.BooksArray.length - 1;
this.BooksArray[pos].ArrayID = pos;
this.BooksArray[pos].DivID = divID;
this.BooksArray[pos].Contents = sContents;
}
this.DelBook = function(divID) {
this.BooksArray.splice(...);
}
}
function CBook() {
this.ArrayID = 0;
this.DivID = "";
this.Contents = "";
}
</code></pre>
<p>I initialize the object like this:</p>
<pre><code>var oBooks = new CBooks();
</code></pre>
<p>I add a new book like this :</p>
<pre><code>oBooks.AddBook("divBook1", "blahblahblah");
//Creation of the div here
oBooks.AddBook("divBook2", "blehblehbleh");
//Creation of the div here
</code></pre>
<p>Now the user can click an X button in the div displaying each book, so that he can delete the book. So the X button contains:</p>
<pre><code>onclick=oBooks.DelBook(this.id);
</code></pre>
<p>Now obviously in the <strong>DelBook(divID)</strong> function I could loop through the length of the <strong>BooksArray</strong> and see each element if it's divID is equal to the parameter and splice at that point, but I want to avoid the looping.</p>
<p>Is there any way to do it ?</p>
<p>thanks in advance</p>
| javascript | [3] |
4,090,586 | 4,090,587 | request query convert from vb to c# | <p>this code is made by vb,page name:main.aspx</p>
<p>when i type the url like that main.aspx?sStyle=0
it type word Yes in the page</p>
<p>and if i type the url like that main.aspx?sStyle=0
it type word No in the page</p>
<pre><code><%@ Page Language=VB Debug=true %>
<%
Dim sStyle
If Request.QueryString("sStyle") = "0" Or Len(Request.QueryString("sStyle")) = 0 Then
Me = 0
ElseIf Request.QueryString("sStyle") = "1" Then
Me = 1
End If
%>
<%If sStyle = "0" Then%>
Yes
<%End If%>
<%If sStyle = "1" Then%>
No
<%End If%>
</code></pre>
<p>=========================================================</p>
<p>my question is how do i make the exact same page using c#</p>
<p>Regards</p>
| c# | [0] |
2,164,284 | 2,164,285 | Where can I find the "clamp" function in .NET? | <p>I would like to clamp a value <code>x</code> to a range <code>[a, b]</code>:</p>
<pre><code>x = (x < a) ? a : ((x > b) ? b : x);
</code></pre>
<p>This is quite basic. But I do not see a function "clamp" in the class library - at least not in <code>System.Math</code>.</p>
<p>(For the unaware to "clamp" a value is to make sure that it lies between some maximum and minimum values. If it’s greater than the max value, then it’s replaced by the max, etc.)</p>
| c# | [0] |
3,733,268 | 3,733,269 | Android tab emulator blurs images, pls suggest | <p>I'm trying to develop for an android tab with the resolution of 1280x720. But when I place an image, say 1000x500, into the xml view it appears almost two times smaller. When I change its height and width from wrap_content to 1000px and 500px, it looks ok in xml, but when I launch it in the emulator, it gets very blurry, as if it would be at first scaled down and then expanded again.</p>
<p>Any ideas?</p>
<p>Thanks!</p>
| android | [4] |
3,621,247 | 3,621,248 | How to upload my phonebook contacts into MS SQL server | <p>I want to select my phone book contacts after that upload all my selected contacts into SQL Server</p>
| android | [4] |
2,186,035 | 2,186,036 | android: eclipse compile error | <p>I create ninepatch image and copy it into drawable folders, the project becomes error, seems that the file cause error and not supported. I use photoshop to create PNG image then edit it using draw9patch tool.I'm using Eclipse 3.5 on win7 with latest sdk update.</p>
<p>Another thing is that he accept another ninepatch image(titlelogin.9.png), but not accept (logohead.9.png)</p>
<p>Here is my draw9patch image and error image.</p>
<p><a href="http://i.stack.imgur.com/3e3xo.jpg" rel="nofollow">project folder image</a></p>
<p><a href="http://i.stack.imgur.com/tU5KE.png" rel="nofollow">logohead.9 img</a></p>
| android | [4] |
2,057,206 | 2,057,207 | Javascript slideshow won't stop | <p>I'm creating a web page with a slide show activated by clicking a button. When I click the button the first time, I want the user to be prompted with how fast they want it to change to the next image before actually running the slide show. The next time the button is clicked, I want the slideshow to stop. Right now the first part is working, but when I click it a second time it just shows the prompt again and doesn't stop the slideshow. Can anyone tell me what I'm doing wrong? Here is my code for the given function:</p>
<pre><code>function slideShow(){
var temp2 = 0;
if (temp2 == 0){
var speed = prompt("How fast would you like to the slideshow to go?");
var timerID = setInterval("clock()",speed);
temp2 = 1;
}
else if (temp2 == 1){
clearInterval(timerID);
temp2 = 0;
}
}
</code></pre>
| javascript | [3] |
4,020,638 | 4,020,639 | calculate TOTAL CONSUMPTION and Consumption per person | <p>I try to calculate calculate TOTAL Consumption and Consumption per person.</p>
<p>Relevant code :</p>
<pre><code>$(function () {
$(".items").keyup(function (event) {
var total = 0;
$(".items").each(function () {
var gtotal = 0;
$(this).find(".targetfields").each(function () {
var qty = parseInt($(this).find(".quantity").val()||'0');
var rate = parseInt($(this).find(".rate").val()||'0');
var subtotal = qty * rate;
$(this).find(".subtotal").val(subtotal);
if (!isNaN(subtotal)) gtotal += subtotal;
});
$(this).find(".g_total").html(gtotal + "Din");
total += gtotal;
});
$("#total").html(total + "Din");
});
});
</code></pre>
<p>A fiddle for the tests : <a href="http://jsfiddle.net/Odisej/CgeHU/" rel="nofollow">http://jsfiddle.net/Odisej/CgeHU/</a></p>
<p>I get stuck...What's wrong in this script?</p>
| javascript | [3] |
628,760 | 628,761 | How can we set a large UIImage on small UIImageview | <p>I am using imagview with size of 320X320 to display large image (350 X 783).</p>
<p>While placing the large image into the imageview, the image looks squeezed, compressed something not like the quality one.</p>
<p>My question is, how can I make the large image into small with as good quality as the original image ?</p>
| iphone | [8] |
1,644,717 | 1,644,718 | javascript setinterval function problem | <p>i am using this code</p>
<pre><code> <a onclick="javascript:var t=setInterval("GetUpdates(5,ajaxResult)",300);">GetUpdates</a>
</code></pre>
<p>but getting the syntax error</p>
| javascript | [3] |
4,259,562 | 4,259,563 | Toggle background of multiple table cells while mouse botton clicked |
<p>I have a weekly calendar, where I want to highlight multiple hours with one "mousedown + move over cells + mouseup". And again remove highlight (invert) the same way.</p>
<p><a href="http://jsfiddle.net/yTd4Q/13/" rel="nofollow">http://jsfiddle.net/yTd4Q/13/</a></p>
| jquery | [5] |
1,503,603 | 1,503,604 | opposite of jQuery find() that isn't not()? | <p>Given the following HTML, what jQuery selector would select the last 'blah blah' <code>span</code> but not the first?</p>
<pre><code><div class='d1'>
<span>
<a>blee
<span> <!-- don't select this span -->
<span>blah</span> blah
</span>
</a>
</span>
</div>
<br/>
<div class='d1'>
<span>
<a>blee
<span> <!-- select this span -->
blah blah
</span>
</a>
</span>
</div>
</code></pre>
<p>I've tried variations using not() but can't figure it out. It seems like what I need is a selector that finds the first span, but then excludes it if it contains another span. Something like:</p>
<pre><code>$('.d1 span a span').not(':has("span")')
</code></pre>
<p>but that doesn't do it. What am I missing?</p>
| jquery | [5] |
4,369,522 | 4,369,523 | Button that generates a random number between 1 and 100 on textview | <p>Thats An easy questions for those who been in the android coding scene for long enought ! I have done researches , Studies about this questions. Tried it , But always had errors when Ran the application. </p>
<p>The questions is , How could I make a button , Show a Random number between 1 and 100 on a textview ? </p>
| android | [4] |
5,072,284 | 5,072,285 | Show tick Symbol on label | <p>I have to show "√" (Tick symbol) in label text. How can show tick symbol on label</p>
<p>Thanks</p>
| c# | [0] |
4,569,707 | 4,569,708 | Euler #18 with Python | <p>I am trying to solve <a href="http://projecteuler.net/problem=18" rel="nofollow">project euler problem 18</a>.
<a href="http://projecteuler.net/problem=18" rel="nofollow">http://projecteuler.net/problem=18</a>
I tried a greedy algorithm with python working from the bottom of the triangle.
THen I move up one row and find the biggest route with a greedy algorithm and try to connect the biggest route but it doesn't work. DO you have any hints that would put me on the right track without giving the solution of the problem away.</p>
<p>here is the function:</p>
<pre><code>def greedy(i):
if i%15==0:
a=[(b[i-15],i-15),(b[i-14],i-14)]
a=sorted(a)
a=a[-1]
else:
a=[(b[i-15],i-15),(b[i-16],i-16),(b[i-14],i-14)]
a=sorted(a)
a=a[-1]
return a
</code></pre>
<p>Cheers</p>
| python | [7] |
1,452,396 | 1,452,397 | Removing character from php string variable | <p>I have a variable in PHP like <code>Logo™</code>. How do I remove the character <code>™</code>, if it's present?</p>
| php | [2] |
2,612,275 | 2,612,276 | copying hashmaps | <p>I have a structure </p>
<pre><code>HashMap<String,HashMap<Integer, HashMap<Integer, question>>> lang=new HashMap<String,HashMap<Integer, HashMap<Integer, question>>>();
HashMap<Integer,HashMap<Integer,question>> section= new HashMap<Integer,HashMap<Integer,question>>();
HashMap<Integer,question> questions= new HashMap<Integer,question>();
</code></pre>
<p>based on my logic I fill questions, section</p>
<pre><code>while(logic){
for(someother logic){
//make the skeleton structure of the object
questions.add(integer,object);
}
section.add(integer,map3);
}
</code></pre>
<p>now I use this map2 as a skeleton and make changes </p>
<pre><code>HashMap<Integer,HashMap<Integer,object>> tempMap= new HashMap<Integer,HashMap<Integer,object>>();
while(logicnew){
while(logic 2){
tempMap = new HashMap(section);
while(logic 3){
tempMap2 = new HashMap(tempMap.get(integer));
//make my changes
}
}
lang.add(integer,tempMap);
}
</code></pre>
<p>Multiple languages have multiple sections, multiple sections have multiple questions.
The problem is the values are getting over written i.e. if I have french text in the first language and english text in the second language, I just see english text in both the lang maps I make. Could you please tell what is wrong? Let me know if there is any better way to do it.</p>
<p>Thanks!</p>
| java | [1] |
74,255 | 74,256 | scrollTop stuck at zero | <p>I am trying to get the vertical position on scroll of page but it is stuck at <code>0</code> value.</p>
<pre><code>window.onscroll=f;
function f() {
document.getElementById('div1').innerHTML=document.body.scrollTop;
}
</code></pre>
| javascript | [3] |
3,467,592 | 3,467,593 | Random image with link on load, without loading them all | <p>I do not want all of the images to load, only the one randomly chosen image. I cannot figure out if the other images are hidden but loading in the background. Each image needs a hyperlink attached.</p>
<pre><code><SCRIPT LANGUAGE="Javascript">
function banner() { } ; b = new banner() ; n = 0
b[n++]= "<a href='#'><img src='main_theme/top_gallery/gallery1.jpg' /></a>"
b[n++]= "<a href='#'><img src='main_theme/top_gallery/gallery2.jpg' /></a>"
b[n++]= "<a href='#'><img src='main_theme/top_gallery/gallery3.jpg' /></a>"
b[n++]= "<a href='#'><img src='main_theme/top_gallery/gallery4.jpg' /></a>"
b[n++]= "<a href='#'><img src='main_theme/top_gallery/gallery5.jpg' /></a>"
i=Math.floor(Math.random() * n) ;
document.write( b[i] )
</SCRIPT>
</code></pre>
| javascript | [3] |
924,920 | 924,921 | Python - Steam User Status | <p>I've been looking for a method to get a steam users status. This includes things like the game they're playing, if they're online or if they're offline. I was originally going to scrape the page, but I figured there must be an easier way to do it.</p>
<p>I looked around for pages which might be json of the users current status, perhaps even an API. But I haven't found anything yet.</p>
<p>Any answers would be appreciated, thanks very much.</p>
<p>-RLR</p>
| python | [7] |
2,170,908 | 2,170,909 | How to add 2 tables in same page in MS word using Microsoft.Office.Interop.Word? | <p>I have a requirement like i have to add 2 tables in same page like page no 4, currently am using Microsoft.Office.Interop namespace,but when i add second table it is place inside 1st table 1st cell how to achieve this?</p>
<p>1st table:</p>
<pre><code>Microsoft.Office.Interop.Word.Table newtable = questionClient.ActiveWindow.Selection.Tables.Add(questionClient.ActiveWindow.Selection.Range, 7, 2, ref defaultBehaviour, ref autoFitBehaviour);
newtable.Cell(1, 1).Range.Text = "\t \t \t Description \t \t";
</code></pre>
<p>2nd table:</p>
<pre><code>Microsoft.Office.Interop.Word.Table newtable2 = questionDoc.ActiveWindow.Selection.Tables.Add(questionClient.ActiveWindow.Selection.Range, 7, 2, ref defaultBehaviour, ref autoFitBehaviour);
</code></pre>
<hr>
<p>2nd table will place inside 1st table ie Cell(1,1);</p>
| asp.net | [9] |
1,583,261 | 1,583,262 | Can i store document.getElementById('id').value in a variable in php like this | <pre><code><?php $id= "document.getElementById('id').value" ;
$id= "document.getElementById('id').value";
?>
</code></pre>
<p>Actually i want to do</p>
<pre><code>document.form.action='".HTTP_PATH."search_list.php/".$id."/".$city."';
</code></pre>
| php | [2] |
2,555,636 | 2,555,637 | Return GeoPoint(s) relative to user using line-of-site outside of MapView | <p>I am currently writing a script to find the closest <code>GeoPoint</code> (from a list of <code>GeoPoints</code> located on our servers) relative to the user, however I came across and interesting idea on limiting results even further.</p>
<p>I am wondering if it is possible to take the Users current line-of-site, maybe using the <code>Compass</code> in order to ignore <code>GeoPoint</code>(s) that may or may not be closer to the user located behind them. I am not looking for this code to be written for me, just a nudge in the right direction or any suggestions, I have searched for the past couple days and am coming up empty.
<em>When I say "line-of-site" I don't mean to specify a cone as shown below, limiting to a direction of N, S, E or W would be fine.</em></p>
<p>In the exmaple picture below I want the results to show only GeoPoint(2):</p>
<p><img src="http://i.stack.imgur.com/6mJnb.png" alt=""></p>
<p><strong>Explanation of use:</strong> The user goes to a location to take photos of <em>several things</em> at said location. In my Camera Activity I am writing a script to show a historic photo of one of the elements on-site relative to their location. All site-specific historic photos and their Coordinates have been retrieved and parsed using JSON.</p>
| android | [4] |
386,783 | 386,784 | Jquery: Forget the DOM structure, just find the next element with this class | <p>I feel like this question has been asked before but the answers seem pretty specific to each poster. </p>
<p>I'm looking for a way to identify a given element and find the next element that has a particular class. I don't want to have to deal with parent() or children() since I'm parsing through a table and I don't want it to stop at the end of a row or even the end of the table itself (there are two side-by-side).</p>
<p>Is there any way to just search the entire page for the next instance of an element?</p>
<p>BACKGROUND INFO:
<a href="http://jsfiddle.net/HKkAa/2/" rel="nofollow">http://jsfiddle.net/HKkAa/2/</a></p>
<p>I'm trying to iterate through the bottom table starting at the highlighted cell and applying the "highlight" class to each cell until I reach the end date. I have a way to calculate when I've reached the end date, I just need the magic method to select the next instance of a link.</p>
| jquery | [5] |
5,236,338 | 5,236,339 | In PHP, how does include() exactly work? | <p>How does <code>include('./code.php');</code> work? I understand it is the equivalent of having the code "pasted" directly where the include occurs, but, for example:</p>
<p>If I have two pages, <code>page1.php</code> and <code>page2.php</code>, of which I would need to manipulate different variables and functions in <code>./code.php</code>, does <code>include()</code> create a copy of <code>./code.php</code>, or does it essentially link back to the actual page <code>./code.php</code>?</p>
| php | [2] |
366,114 | 366,115 | What does this mean? initWithFrame:CGRectZero] | <p>I created switch in cellForRowAtIndexPath like this.</p>
<p>UISwitch *switchView = [[UISwitch alloc] initWithFrame:CGRectZero];</p>
<p>CGRectZero is equivalent to CGRectMake(0,0,0,0).
But, switch is seen in normal size.
I didn't specified actuall size.
Please explain to me how above code works.</p>
| iphone | [8] |
4,391,627 | 4,391,628 | how to i know in my application, when i sent new message? | <p>I am developing one application related to messages.</p>
<p>in my application i am getting all sent messages,by using contentresolver.</p>
<p>the code is</p>
<pre><code>c = getContentResolver().query(SMS_sent,null, null, null, null);
startManagingCursor(c);
if(c!=null)
{
((LinearLayout)findViewById(R.id.linearLayout11)).setVisibility(View.GONE);
String columns ="body";
String columns1 = "address";
SimpleCursorAdapter adapter2 = new SimpleCursorAdapter(this, R.layout.main2,c,
new String[] {columns1,columns}, new int[]{R.id.textView2, R.id.textView4});
ListView empListView = (ListView)findViewById(R.id.listView1);
empListView.setAdapter(adapter2);
}
</code></pre>
<p>it is working fine.</p>
<p>my requirement is when i am sending new message,</p>
<p>i want to hanlde that in my application.</p>
<p>If any one know the solution,Please help me</p>
<p>Thanks in advance</p>
| android | [4] |
3,176,590 | 3,176,591 | How can i make a session control in asp.net so that I can have 2 users logged in at the same time? | <p>So I have a web page where different users with passwords can login. How can i make a session control in asp.net so that I can have 2 users logged in at the same time.</p>
| asp.net | [9] |
2,675,174 | 2,675,175 | Effective way to find particular directory name? | <p>I have a script that I've written that I sell to others who want a virtual gift application on Facebook. As many of the customers who buy this script don't actually have programming knowledge, I try to simplify things as much as is possible for them by gathering as much data as I can without their input (such as using <code>$_SERVER</code> vars).</p>
<p>I'm running into a problem when trying to establish a static directory for images, though, that the code can read and always know where that directory is.</p>
<p>For instance, on my 'masterfile.php' which is included on most every page I have this:</p>
<pre><code>$app_info['server_url']="http://".$_SERVER['SERVER_NAME'];
$app_info['callback_url']=$app_info['server_url'].dirname($_SERVER['PHP_SELF'])."/";
$app_info['image_url']=$app_info['callback_url'].'images/';
</code></pre>
<p>That gives me all the necessary information I need about where folders are located... unless I'm using a directory inside the parent directory to the entire script (IE: /folder/ajax/).</p>
<p>I'm running into a problem where the 'images' folder needs to always be '/folder/images/' instead of ending up as '/folder/ajax/images/' when working with other directories inside the parent.</p>
<p>I can't just hard code the parent directory name as some customers upload them to directories such as '/folder/folder/folder/folder/script/' - that's why I use <code>$_SERVER['PHP_SELF']</code> to establish the parent directory.</p>
<p>Is there a way (or a variable) that I can use for this problem? I just need to ensure that the <code>$app_info['callback_url']</code> is always the same, regardless of the current directory.</p>
<p>Thanks!</p>
| php | [2] |
3,597,205 | 3,597,206 | How to Encyrpt Session Values in Android | <p>I'm developing an Android app which based on a web-server. Users, who installed the app, should register on web, so they can login. When someone try to login I verify their information with <code>API</code>.</p>
<p>So I'm curious about persisting and <strong>encryption processes</strong>. Should I encrypt the values or just put them all to <code>SharedPreferences</code>? If encryption is needed what's the efficient way?</p>
<p>And last but not least, Is SharedPreferences enough in terms of security?</p>
<p>Thanks.</p>
| android | [4] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.