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 |
|---|---|---|---|---|---|
3,737,216 | 3,737,217 | How to determine if a number is odd in JavaScript | <p>Can anyone point me to some code to determine if a number in JavaScript is even or odd?</p>
| javascript | [3] |
4,028,222 | 4,028,223 | Multiple derivations of the same object | <p>I don't know what this is called but here goes.</p>
<pre><code>public class Person
{
long ID;
}
public class Banker : Person
{
string example1;
}
public class Scientist : Person
{
string example2;
}
</code></pre>
<p>I'm trying implement our ORM to match our database and I ran into this problem. Hopefully this example is easy enough to understand.</p>
<p>Now the object-relation mapping makes sense for a person being a Banker or a Scientist. The problem I have been having is the Person being a Banker and a Scientist. So what I'm trying to accomplish is being able to create a Banker or Scientist and being able to cast it to either while having the exact same base class object.</p>
<p>I'm not really looking for multiple inheritance. What I’m looking for is a way to instantiate multiple objects with the same base class object. For example the Person is a Banker and a Scientist but not a Banker Scientist (a class having attributes of both banker and a scientist). </p>
<p>This was actually a flaw in the database and the model is now being change but its still a curios question.</p>
| c# | [0] |
3,039,225 | 3,039,226 | dynamic value in textbox | <p>I have a text box like this:</p>
<pre><code><asp:TextBox ID="txtLogin" runat="server" Text='<%# strUserID %>'></asp:TextBox>
</code></pre>
<p><code>strUserID</code> is a string value set in my codebehind and I bind the textbox to see the value. I tried with <code><%= strUserID %></code>, but it doesnt work for me. can you please tell me why?</p>
<p>Also, I have a hidden field like this:</p>
<pre><code><input id="hdnUserID" runat="server" type="hidden" value='<%=txtLogin.ClientID %>' />
</code></pre>
<p>and I have a function prints the hidden field value like this:</p>
<pre><code>function CheckForValue()
{
var uid = window.document.getElementById('<%= txtLogin.ClientID %>').value;
alert(hdnUserID);
return false;
}
</code></pre>
<p>But this alert always prints as "[object]". Can anyone please explain this? Looks like <code><%= value %></code> doesnt work at all. But I have seen in my earlier projects where the existing code has these kinda lines!!</p>
| asp.net | [9] |
4,943,461 | 4,943,462 | c# cEXWB navigate2 doesn't work on second url | <p>I am trying to use a browser object to get some data from a website. the problem is that for one site i have to redirect, get some other info and then go back to this site.
my coed so far is</p>
<pre><code>private void getInfo(cEXWB browser, string url)
{
if (url == "www.specificwebsite.com")
{
browser.navigate2("www.mywebsite.com");
int myAnswer = getData(browser);
}
browser.navigate2(url);
}
</code></pre>
<p>the problem is that i can NEVER get my browser to navigate 2 times. That is - if i need to navigate to "www.mywebsite.com" - it doesn't navigate to url.
What am i doing wrong?</p>
<p>Thanks!</p>
| c# | [0] |
1,994,980 | 1,994,981 | Clamping values in preference screen | <p>Is there a way to clamp the numerical value entered into a editTextPreference? I'd like to limit a value to say +- 45.</p>
| android | [4] |
3,875,361 | 3,875,362 | Handle event press hardware button Next and Pre? | <p>I want to press hardware button Next will show Next Screen and press hardware button Pre will show Pre Screen (ViewFliper)
What do you know event press hardware button Next and Pre in Android ?
How catch event press hardware button Next and Pre in Android ?
You can watch image at here: <a href="https://www.dropbox.com/s/89pjr15kpxxk1lc/android.jpg" rel="nofollow">enter link description here</a>
Thanks!</p>
| android | [4] |
5,334,955 | 5,334,956 | clear last entry in calculator using C# | <p>I have a string;</p>
<pre><code>string str = "3+4*2+8";
</code></pre>
<p>This string is entered by user..
I want to do an operation in which I just want to remove last entry of string. i.e 8 in this particular example.....
Please guide me how to do this....</p>
| c# | [0] |
4,316,255 | 4,316,256 | show data in listview from webservice according to keypress in android | <p>i am developing a apps for korean client.i have to search a data according to key press. like if i press A then all the data who started from A show in listview where data come from a webservice in listview.is it possible?if yes,then how to do it.if possible give me some code or link which i can use.</p>
<p>thanks</p>
| android | [4] |
2,056,308 | 2,056,309 | R cannot be resolved for inflating raw queries | <p>I know this is a pretty common question and I looked around the web and this forum for an answer but none of them seem to be working for me. I did the typical stuff like deleted my R.java and cleaned my project, made sure my class did not have a import for the R.java class. I tried rebuilding my project etc. </p>
<p>So here is what I have going on. I am trying to inflate a database from some raw SQL statements. I am using the book The Busy Coders Guide to Advanced Android Development book as a guide to do this. </p>
<p>it gives the following line of code:</p>
<pre><code>InputStream stream=ctxt.getResources().openRawResource(R.raw.packaged_db);
</code></pre>
<p>and says the file is located within the res/raw directory like so "res/raw/packaged_db.txt"</p>
<p>I have placed my sql dump file: res/raw/raw_game_data.sql</p>
<p>and here is my line of code that is throwing the error:</p>
<pre><code>InputStream inputStream = context.getResources().openRawResource(R.raw.raw_game_data);
</code></pre>
<p>any ideas or suggestions on what I am missing?</p>
<p>Thanks,</p>
| android | [4] |
1,114,380 | 1,114,381 | What does mean && between variables in line without if? | <p>I have following line of code in javascript:</p>
<pre><code>q && (c = q === "0" ? "" : q.trim());
</code></pre>
<p>WHat does it mean? I understand that <code>c</code> is equals either empty string or q.trim() result, but what does mean <code>q && ()</code>?</p>
| javascript | [3] |
5,222,107 | 5,222,108 | Is there a way of applying a function to each member of a struct in c++? | <p>You have a simple struct, say:</p>
<pre><code>typedef struct rect
{
int x;
int y;
int width;
int height;
}
rect;
</code></pre>
<p>And you want to multiply each element by a factor. Is there a more concise way of performing this operation, other than multiplying each member by the value?</p>
| c++ | [6] |
1,810,487 | 1,810,488 | Achieve similar hardware acceleration optimization in Android 2.3 - Avoid multiple onDraw call | <p>By referring to <a href="http://developer.android.com/training/custom-views/optimizing-view.html#accelerate" rel="nofollow">http://developer.android.com/training/custom-views/optimizing-view.html#accelerate</a>, I know that I can avoid multiple system call on busy <code>onDraw</code> by using <code>setLayerType(View.LAYER_TYPE_HARDWARE, null);</code>.</p>
<p>I tested on Android 4, by performing home -> restore -> home. I realize <code>onDraw</code> will only be called once as stated in the above android documentation.</p>
<p>However, how can I achieve the similar optimization in Android 2.3? As Android 2.3 doesn't support hardware optimization.</p>
<pre><code>public class PieChart extends View {
@SuppressLint("NewApi")
public PieChart(Context context) {
super(context);
mPiePaint = new Paint();
mPiePaint.setAntiAlias(true);
mPiePaint.setStyle(Paint.Style.FILL);
mPiePaint.setColor(0x88FF0000);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
if (!isInEditMode()) {
setLayerType(View.LAYER_TYPE_HARDWARE, null);
}
}
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
Log.i("CHEOK", "Busy onDraw is called");
canvas.drawArc(mBounds,
0,
200,
true, mPiePaint);
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
mBounds = new RectF(0, 0, w, h);
}
private RectF mBounds;
private Paint mPiePaint;
}
</code></pre>
| android | [4] |
5,455,884 | 5,455,885 | Not able to call run method | <p>When I am running my Batch Application Program(below one), it gets inside the execute method firstly, and then whenever it tries to make an instance of CoreTask() it is not hitting the run method in the CoreTask class, Is there anything wrong?</p>
<pre><code>public class PDSBatchTask extends Task {
public TaskResponse execute() {
try {
Runnable coreTask = new CoreTask();
ScheduledFuture<?> scheduledFuture = Executors.newScheduledThreadPool(1).scheduleWithFixedDelay(coreTask, 0, 10, TimeUnit.MILLISECONDS);
return new TaskResponse(
PDSTestingBatchExitCodeEnum.EXIT_CODE_SUCCESS);
} catch (Exception e) {
}
}
private static final class CoreTask implements Runnable {
// When I put a breakpoint here, it doesn't hit the run method.
public void run() {
CommandExecutor commandExecutor = CommandExecutor.getInstance();
commandExecutor.runNextCommand();
}
}
}
</code></pre>
| java | [1] |
3,220,915 | 3,220,916 | How to give empty space between rows of listview? | <p>In my application I have a requirement of listview with empty spaces between rows of list.So that I can give background to each row and it will look something like blocks of rows.</p>
<p>I tried my best but didnt find any solution.</p>
| android | [4] |
2,308,432 | 2,308,433 | How to Rotate TextView? | <p>I want to rotate TextView but I can't get proper output. I am getting <code>textView</code> with missing some text</p>
<p><strong>In Layout</strong></p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_marginTop = "50dip">
<TextView android:layout_width="wrap_content" android:gravity="bottom"
android:layout_height="wrap_content" android:id="@+id/text"
android:text="Shreeji \n Nath" />
</RelativeLayout>
</code></pre>
<p><strong>In Animation</strong></p>
<pre><code> <?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="40" android:toDegrees="-90" android:pivotX="40%"
android:duration="0">
</rotate>
</code></pre>
<p><strong>Java file</strong></p>
<pre><code>import android.app.Activity;
import android.os.Bundle;
import android.view.animation.AnimationUtils;
import android.view.animation.RotateAnimation;
import android.widget.TextView;
public class VDemo extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TextView tv = (TextView)findViewById(R.id.text);
RotateAnimation ranim = (RotateAnimation)AnimationUtils.loadAnimation(this,R.anim.myanim);
ranim.setFillAfter(true);
tv.setAnimation(ranim);
}
}
</code></pre>
| android | [4] |
1,492,364 | 1,492,365 | problem convert idl to tlb | <p>i try to get a selected text and the word under mouse in firefox</p>
<p>after a lot of search i get the solution that i must access a document's HTML in Firefox using IAccessible</p>
<p>i found that solution in c++ in this link
<a href="http://stackoverflow.com/questions/542395/how-to-access-a-documents-html-in-firefox-using-iaccessible">How to access a document's HTML in Firefox using IAccessible</a></p>
<p>the solution use ISimpleDOMNode.idl file so the first step to convert that solution from c++ to c# is convert </p>
<p>ISimpleDOMNode.idl to tlb file and convert tlb to dll fill</p>
<p>i try to use VS Command Prompt with this command to convert to tlb file
midl ISimpleDOMNode.idl</p>
<p>but That generate ISimpleDOMNode.h and ISimpleDOMDocument.h, which define the interfaces. It also create ISimpleDOMNode_i.c and ISimpleDOMDocument_i.c but there is no tlb file</p>
<p>what is the wrong ?</p>
<p>this the link of ISimpleDOMNode.idl file</p>
<p><a href="http://www.4shared.com/file/MddCFmXa/ISimpleDOMNode.html" rel="nofollow">http://www.4shared.com/file/MddCFmXa/ISimpleDOMNode.html</a></p>
| c# | [0] |
1,400,358 | 1,400,359 | how convert date string format into UTC+0530 format using javascript? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/4990367/converting-a-date-string-into-utc0530-format-using-javascript">Converting a date string into UTC+0530 format using javascript</a> </p>
</blockquote>
<p>I have date is "<code>14-Feb-2011</code>" in this form and </p>
<p>i wants convert into <code>Mon Feb 14 10:13:50 UTC+0530 2011</code> format </p>
<p>using <strong>javascript</strong></p>
| javascript | [3] |
3,003,974 | 3,003,975 | iPhone SDK - How to Tell if a Text Field Has Text? | <p>Sorry for the simple question but I feel like there's a smarter way to do this:</p>
<pre><code>if ([txtFldTo.text length]>0){
//do something
}
else {
//do something else
}
</code></pre>
<p>where txtFldTo is an IBOutlet UITextField connected to a text field on the interface.</p>
| iphone | [8] |
4,516,330 | 4,516,331 | I cant solve expression involving str.find() | <p>I got a problem:</p>
<blockquote>
<p>Variables <code>s1</code> and <code>s2</code> refer to strs. The expression <code>s1.find(s2)</code>
returns the index of the first occurrence of s2 in s1.</p>
<p>Write an expression that gives the index of the second occurrence of
<code>s2</code> in <code>s1</code>. If <code>s2</code> does not occur twice in <code>s1</code>, the expression
should evaluate to -1. Unlike <code>str.count</code>, you should allow
overlapping occurrences of <code>s2</code>.</p>
<p>Your answer must be a single expression that does not use the square
bracket notation, and you can only call method str.find and use the
arithmetic operators (+, -, etc.).</p>
</blockquote>
<p>Is this answer correct?</p>
<pre><code>s1.find('s2',(s1.find('s2')+1))
</code></pre>
<p>Thanks</p>
| python | [7] |
4,743,261 | 4,743,262 | What is the best way to find all files on SD card with a certain extension? | <p>What is the best way to find all files with a defined custom extension on the SD card?
Are there any filters or maybe some techniques?</p>
<p><strong>EDIT:</strong></p>
<p>What is the best way to find all .txt files on my SD - Card ?</p>
| android | [4] |
3,123,711 | 3,123,712 | Is there a convention to the order of modifiers in C#? | <p>If I were to use more than one, what order should I use modifier keywords such as:</p>
<p>public, private, protected, virtual, abstract, override, new, static, internal, sealed, and any others I'm forgetting.</p>
| c# | [0] |
2,016,273 | 2,016,274 | really weird symbol in php? | <p>what does the ∫ symbol mean in php? Here is copy/paste of my var dump.. note the @user_id symbol then(0). Thanks! `` <br> <pre><code> object(dbStoredProcedure)#13 (9) {
["dbh:private"]=>
resource(27) of type (mssql link)
["sp_name:private"]=>
string(24) "[dbo].[user_account_ins]"
["sp_parameters:private"]=>
array(0) {
}
["stmt:private"]=>
resource(50) of type (mssql statement)
["parameters"]=>
array(2) {
["@error"]=>
&string(0) ""
["@user_id"]=>
∫(0)
}
["results"]=>
array(0) {
}
["result"]=>
array(0) {
}
["query"]=>
NULL
["error"]=>
bool(false)
}
</code></pre></p>
| php | [2] |
5,686,690 | 5,686,691 | Cannot understand the behaviour of C# compiler while instantiating a class thru interface | <p>I have a class that implements an interface. The interface is </p>
<pre><code>public interface IRiskFactory
{
void StartService();
void StopService();
}
</code></pre>
<p>The class that implements the interface is </p>
<pre><code>public class RiskFactoryService : IRiskFactory
{
}
</code></pre>
<p>Now I have a console application and one window service.</p>
<p>From the console application if I write the following code</p>
<pre><code>static void Main(string[] args)
{
IRiskFactory objIRiskFactory = new RiskFactoryService();
objIRiskFactory.StartService();
Console.ReadLine();
objIRiskFactory.StopService();
}
</code></pre>
<p>It is working fine. However, when I mwrite the same piece of code in Window service</p>
<pre><code>public partial class RiskFactoryService : ServiceBase
{
IRiskFactory objIRiskFactory = null;
public RiskFactoryService()
{
InitializeComponent();
objIRiskFactory = new RiskFactoryService(); <- ERROR
}
/// <summary>
/// Starts the service
/// </summary>
/// <param name="args"></param>
protected override void OnStart(string[] args)
{
objIRiskFactory.StartService();
}
/// <summary>
/// Stops the service
/// </summary>
protected override void OnStop()
{
objIRiskFactory.StopService();
}
}
</code></pre>
<p>It throws error: <strong>Cannot implicitly convert type 'RiskFactoryService' to 'IRiskFactory'. An explicit conversion exists (are you missing a cast?)</strong></p>
<p>When I type cast to the interface type, it started working</p>
<pre><code>objIRiskFactory = (IRiskFactory)new RiskFactoryService();
</code></pre>
<p>My question is why so?</p>
| c# | [0] |
1,753,432 | 1,753,433 | Is is possible to dynamically load a user control at runtime based on a condition within an UpdatePanel? | <p>I need to conditionally load a few nested user controls on a webpage based on a dropdown selection that fires a callback. Is this possible? Are there any best practices for such an approach?</p>
| asp.net | [9] |
1,797,768 | 1,797,769 | $('#display).text() returning as [object%20Object] | <p>I'm trying to get what's inside a <code><div></code> with ID of <code>display</code> using</p>
<pre><code>$("#display").after(html);
var testxd = $("#display").text();
window.location.replace("test.php?v="+testxd);
</code></pre>
<p>and all I get is a BLANK. I Help?</p>
<p>Here is div <code>display</code>:</p>
<pre><code><div id="display" style="display: none;"></div>
</code></pre>
<p>I know the ID is in the because the ID shows up during <code>after(html)</code>;</p>
| jquery | [5] |
822,770 | 822,771 | Anonymous Method Not Working | <pre><code>ComboBoxEdit encoderCombo =
{
if (slot==1) return cmbEncoder1;
else if (slot==2) return cmbEncoder2;
else if (slot==3) return cmbEncoder3;
else return cmbEncoder4;
};
</code></pre>
| c# | [0] |
5,590,523 | 5,590,524 | Casting custom types | <p>I'm working on a custom struct and I would like to give it the ability to implicitly be created from another type.</p>
<p>Say I have two struct types. Color and ColorX, where Color is a struct already in the framework that I cannot change.</p>
<p>Using implicit operator, to be able to say for example.</p>
<pre><code>Color C;
ColorX CX;
CX = new ColorX();
C = CX;
</code></pre>
<p>However, I would like to be able to do it the other way around as well. Either by directly setting it, or by making a cast. Being able to do both would be gold. For example.</p>
<pre><code>C = new Color();
CX = C;
</code></pre>
<p>or cast it like so:</p>
<pre><code>CX = (ColorX)C;
</code></pre>
<p>Consider all the other useful operators in C#, I'm sure there is a way to do this, I just can't find the syntax.</p>
<p>Any help is greatly appreciated! Thank you very much.</p>
| c# | [0] |
471,866 | 471,867 | Difference between method overloading and overriding in java? | <p>What are the differences between method overloading and overriding. Can anyone explain it with an example.?</p>
| java | [1] |
1,259,085 | 1,259,086 | how i can get parts of web pages by php | <p>i want make a news site gets its content from other news sites,
open the rss feed and feach url and open the html dom of the page then
get just the text of the news
i think i have to use the DOMDocument class of the php?</p>
<pre><code><?php
$doc = new DOMDocument();
$doc->loadHTML("<html><body>Test<br></body></html>");
echo $doc->saveHTML();
?>
</code></pre>
<p><a href="http://www.php.net/manual/en/class.domdocument.php" rel="nofollow">http://www.php.net/manual/en/class.domdocument.php</a></p>
| php | [2] |
39,575 | 39,576 | Getting punctuation from the end of a string only | <p>I'm looking for a C# snippet to remove and store any punctuation from the <strong>end of a string only</strong>.</p>
<p>Example:</p>
<ul>
<li>Test! would return !</li>
<li>Test;; would return ;;</li>
<li><p>Test?:? would return ?:?</p></li>
<li><p>!!Test!?! would return !?!</p></li>
</ul>
<p>I have a rather clunky solution at the moment but wondered if anybody could suggest a more succinct way to do this.</p>
<p>My puncutation list is </p>
<pre><code>new char[] { '.', ':', '-', '!', '?', ',', ';' })
</code></pre>
| c# | [0] |
743,246 | 743,247 | python call another script in new terminal | <p>I use my python script for pentest
and I want to call another script in a new terminal.
I'm getting the error "There was an error creating the child process for this terminal"
if I use this line with space it only opens a new terminal with python shell but it doesn't read the path of the new script /root/Desktop/script/WPA1TKIP.py</p>
<pre><code>os.system("gnome-terminal -e python /root/Desktop/script/WPA1TKIP.py")
</code></pre>
<p>Where did I go wrong?</p>
<pre><code>#!/usr/bin/python
import os
bssid_ap = '7C:03:4C:BA:72:F9'
spoof_mac = 'aa:bb:cc:dd:ee:ff'
interface = 'wlan0'
cap_file_name = 'hot'
new_interface = 'mon0'
ssid = 'hot'
channel_number = '1'
raw_input("\n welcome M0ntanaT press to kik target..")
print
#start aireplay-ng to send deauth to station
raw_input ("" "press to start kik target..")
aireplay = "aireplay-ng --deauth 5 " " " "-a " + bssid_ap + " " + new_interface
os.system(aireplay)
os.system("gnome-terminal -e python /root/Desktop/script/WPA1TKIP.py")
#repeat send deauth to station
retry_yes = "r"
retry_no = "c"
print "\n \n If the attack was unsuccessful, press 'r' to retry."
print "" " If the attack was successful, press ' c ' to continue."
def fake_auth():
os.system(aireplay)
while 1:
retry = raw_input("\n Press ' r ' to retry or ' c ' to continue.. ")
if retry == retry_yes:
fake_auth()
if retry == retry_no:
break
</code></pre>
| python | [7] |
4,693,690 | 4,693,691 | show time in seconds in decrease mode. In table view: iphone | <p>I have a table view with 5 rows. The first row shows a decreasing digit indicating the time in seconds, i.e 30, 29, 28 ... 0. This is for the user to choose an action from the table view within 30 seconds. How is this implemented?</p>
| iphone | [8] |
4,219,664 | 4,219,665 | Txt file input error Java | <p>I'm getting the error </p>
<pre><code>Exception in thread "main" java.lang.NumberFormatException: For input string: "scores.txt"
at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1222)
at java.lang.Double.parseDouble(Double.java:510)
at ExamAverage.main(ExamAverage.java:30)
C:\Users\Peter\AppData\Local\Temp\codecomp5461808896109186034.xml:312: Java returned: 1
</code></pre>
<p>for my code listed below what does this error mean? I'm trying to go line by line from a given text file path and output it in a certain format.</p>
<pre><code> import java.io.FileReader;
import java.io.FileNotFoundException;
import java.util.Scanner;
import java.io.PrintWriter;
public class ExamAverage
{
public static void main(String[] args)
throws FileNotFoundException
{
String inputFileName = "scores.txt";
String outputFileName = "examScoreAverage.txt";
Scanner console = new Scanner(System.in);
Scanner in = new Scanner(inputFileName);
PrintWriter out = new PrintWriter(outputFileName);
int TestNumber = 1;
double totalPoints = 0;
double avg = 0;
double test = 0;
while (in.hasNextLine())
{
String line = in.nextLine();
test = Double.parseDouble(line);
out.println("Score" + TestNumber + " : " + test);
totalPoints += test;
TestNumber++;
}
avg = totalPoints/TestNumber;
out.println("Number of scores read: " + TestNumber );
out.println("Average Score " + avg );
in.close();
out.close();
</code></pre>
<p>}
}</p>
| java | [1] |
684,524 | 684,525 | how to handle push notification by the kind of notification | <p>i want to handle the notification, in my app i have 2 tabs(friends,jobs) with navigation controller,and a barbutton on each navigation controller named 'notification'(on click it displays tableview).
On notification, if its job related it shud open the page linked to barbutton on jobs tab and if it is friends related it shud open the page linked to barbutton on friends tab.</p>
| iphone | [8] |
3,238,072 | 3,238,073 | code help for stored procedure dll class | <p>i m making dll class for stored procedure as...help me to correct it...my boss said that i m missing parameter values to return but i m not getting anything to correct it...</p>
<pre><code>public class transactionService
{
SqlConnection cs;
private void OpenConnection()
{
cs = new SqlConnection();
cs.ConnectionString = "Data Source=IRIS-CSG-174;Initial Catalog=library_system;Integrated Security=True";
cs.Open();
}
public membership_details calculatefine()
{
OpenConnection();
SqlCommand cmd = new SqlCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "Exec member_fine_detail";
cmd.Parameters.Add(new SqlParameter("member_id", SqlDbType.Int));
membership_details myObjec = new membership_details();
cmd.ExecuteNonQuery();
SqlDataReader sdr = cmd.ExecuteReader();
myObjec.fine_per_day = 0;
return myObjec;
</code></pre>
<p>help me to correct this code...i m trying to get fne_per_day as per member_id and after this reference is adding to return form in project from that according to member_id fine_per_day is calculated...as the creteria is like member_id=5,membership_desc=silver,gol,platinum,fineperday=30or 20or10</p>
| c# | [0] |
140,978 | 140,979 | how can i show mysql data alphabeticaly | <p>i have the following mysql table....</p>
<pre><code>-----------------------
id customer_name date
-----------------------
</code></pre>
<p>now let me know the query with which i will able to show data Order by alphabeticaly...</p>
<p>where values of customer_fields are like testkhan, rafae, ibrahm and i want to show them as </p>
<p>ibrahm<br>rafae<br>testkhan</p>
| php | [2] |
3,431,831 | 3,431,832 | Find one file out of many containing a desired string in Python | <p>I have a string like 'apples'. I want to find this string, and I know that it exists in one out of hundreds of files. e.g.</p>
<pre><code>file1
file2
file3
file4
file5
file6
...
file200
</code></pre>
<p>All of these files are in the same directory. What is the best way to find which file contains this string using python, knowing that exactly one file contains it.</p>
<p>I have come up with this:</p>
<pre><code>for file in os.listdir(directory):
f = open(file)
for line in f:
if 'apple' in f:
print "FOUND"
f.close()
</code></pre>
<p>and this:</p>
<pre><code>grep = subprocess.Popen(['grep','-m1','apple',directory+'/file*'],stdout=subprocess.PIPE)
found = grep.communicate()[0]
print found
</code></pre>
| python | [7] |
2,414,487 | 2,414,488 | Why following code shows setVideoSource failed exception | <pre><code> MediaRecorder mr=new MediaRecorder();
mr.setVideoSource(MediaRecorder.VideoSource.CAMERA);
</code></pre>
| android | [4] |
5,213,889 | 5,213,890 | OMA DRM v1 & v2 support on Android | <p>Are <a href="http://en.wikipedia.org/wiki/OMA_DRM" rel="nofollow">OMA DRM</a> v1 and v2 supported on Android?</p>
<p>If no, is it planned?</p>
<p>is there any third party library that implements OMA DRAM v1 & v2?</p>
| android | [4] |
2,382,531 | 2,382,532 | Landscape to Portrait recreates activity? | <p>I'm allowing the user to work in both landscape & portrait modes but when I switch between these two modes it just brings the activity to its starting point.</p>
<p>For Example; I enter all the specifications for which I want to view the data in some activity but when I switch the mode from landscape to portrait or portrait to landscape it just brings the activity to its starting point & I've to enter all the specifications again to view my data.</p>
<p>Is there any solution to it or will android always re-create the activity on switching between two modes?</p>
<p>Thanks. :)</p>
| android | [4] |
1,373,992 | 1,373,993 | Why do I need an explicit downcast if my object of type "object" is pointing to the correct instance in hierarchy? | <p>Consider the following inheritance:</p>
<pre><code>abstract class Employee
{
private string empID;
private string empName;
}
class SoftwareDeveloper : Employee
{
............
}
class MarketingPerson : Employee
{
...........
}
static void Main()
{
Employee Jaffer = new SoftwareDeveloper();
Employee George = new MarketingPerson();
// Ok because of is-a relationship
LayOff(Jaffer);
// Ok because of is-a relationship
LayOff(George);
object Leo = new MarketingPerson();
// Error because downcast is required as (MarketingPerson) Leo
LayOff(Leo);
}
static bool LayOff(Employee emp)
{
// some Business Logic
return true;
}
</code></pre>
<p>Even though the declaration <code>object Leo = new MarketingPerson()</code> points to an instance of MarketingPerson, why do I need to downcast?</p>
| c# | [0] |
2,496,894 | 2,496,895 | Get Keyboard input c++ outside of terminal | <p>I am trying to write a c++ program that responds to keyboard input. I want to run this as a daemon so I can't use cin, I would also like to output each character as it is pressed to a picoLCD screen that I have set up. What is the best way to do this?</p>
| c++ | [6] |
2,783,456 | 2,783,457 | Android - Eclipse emulators for all phones? | <p>Hi I want to create multiple emulators to test my applications, but i am not sure for the settings for each emulator, I know the resolutions of common phones, but i am not sure for other settings such as DPI.</p>
<p>I believe "Abstract LCD density" option is for DPI in emulator ? </p>
<p>Emulator1 (For example samsung galaxy ace)
Res: 320x480
Abstract LCD density (DPI): ?</p>
<p>Emulator2 (For example Htc desire S)
Res: 480x800
Abstract LCD density (DPI): ?</p>
<p>Emulator3 (For example galaxy nexus)
Res: 640x960
Abstract LCD density (DPI): ?</p>
<p>Emulator4 (For example Samsung galaxy S III)
Res: 720x1280
Abstract LCD density (DPI): ?</p>
| android | [4] |
4,171,988 | 4,171,989 | Is the `new` keyword in java redundant? | <p>I am coming from C++ so there is one feature of java that I don't quite understand. I have read that all objects must be created using the keyword <code>new</code>, with the exception of primitives. Now, if the compiler can recognise a primitive type, and doesn't allow you to create an object calling its constructor without <code>new</code>, what is the reason to have the keyword <code>new</code> at all? Could someone provide an example when two lines of code, identical except for the presence of <code>new</code>, compile and have different meaning/results? </p>
<p>Just to clarify what I mean by redundant, and hopefully make my question clearer. Does <code>new</code> add anything? Could the language have been expressed without <code>new</code> for instantiation of objects via a constructor? </p>
| java | [1] |
4,748,085 | 4,748,086 | How to draw circle,rectangle manually on android videoplayer | <p>I just wanna draw circle,rectangle or something manually on video player(while video playing) in android.Is it possible?If any code samples are much better.</p>
<p>Thanks.</p>
| android | [4] |
223,285 | 223,286 | php: cannot modify array in function? | <p>so I am trying to modify an array by adding key and value in a function <code>modArr</code>; I expect the var dump to show the added items but I get NULL. What step am I missing here?</p>
<pre><code><?php
$arr1 = array();
modArr($arr1);
$arr1['test'] = 'test';
var_dump($arr);
function modArr($arr){
$arr['item1'] = "value1";
$arr['item2'] = "value2";
return;
}
</code></pre>
| php | [2] |
3,363,403 | 3,363,404 | To Make an item wiggle and delete | <p>I need to delete/remove an item in my Iphone application. For that i should make tat item wiggle(shake) when i give long press. And then it should ask for an alert to delete or not???</p>
<p>Can anyone guide me plz??? It ll be more helpful if u help me with a source code</p>
<p>Tanx in advance</p>
| iphone | [8] |
4,439,932 | 4,439,933 | Google.API.Translate.Translator.Translate method causing proble | <p>Dear Stackoverflow members i would like your kind attention towards my following problem:</p>
<p>i am using google GoogleTranslateAPI version v2.0.50727 dll. when i m executing the following code it is giving <strong>Translate failed!</strong> exception. please help me to sort my problem out.</p>
<pre><code> static void Main(string[] args)
{
string Text = "This is a string to translate";
Console.WriteLine("Before Translation:{0}", Text);
Text = Google.API.Translate.Translator.Translate
(Text,Google.API.Translate.Language.English,
Google.API.Translate.Language.French);
Console.WriteLine("Before Translation:{0}", Text);
Console.Read();
}
Thanks in advance.
regards progchd
</code></pre>
| c# | [0] |
46,332 | 46,333 | Why do these values change like the objects were passed by reference if I set the properties? | <p>Program:</p>
<pre><code> class Program
{
class class1
{
public string Name { get; set; }
public int Value { get; set; }
}
class class2
{
public string Name { get; set; }
public int Value { get; set; }
}
static void Main(string[] args)
{
var Source = new class1() { Name = "Source", Value = 1 };
var Target = new class2() { Name = "Target", Value = 2 };
setValue(Source, Target);
Console.WriteLine(string.Format("Source - Name:{0} Value:{1}", Source.Name,Source.Value));
Console.WriteLine(string.Format("Target - Name:{0} Value:{1}",Target.Name, Target.Value));
}
private static void setValue(object Source, object Target)
{
Target = Source;
}
}
</code></pre>
<p>When this runs I get(which I expected):</p>
<pre><code>Source - Name:Source Value:1
Target - Name:Target Value:2
</code></pre>
<p>But when I change the setValue method to:</p>
<pre><code>private static void setValue(object Source, object Target)
{
var source = Source as class1;
var target = Target as class2;
target.Name = source.Name;
target.Value = source.Value;
}
</code></pre>
<p>I get:</p>
<pre><code>Source - Name:Source Value:1
Target - Name:Source Value:1
</code></pre>
| c# | [0] |
2,621,286 | 2,621,287 | Compare string and floats in python | <p>I have a two lists with values that I want to compare. If the value can be converted to a float, I want to compare the floats else I just want to compare the values as strings. How can I make that distinction to check whether a value can be converted to float or not?</p>
| python | [7] |
4,069,323 | 4,069,324 | Getting SIM state in GsmServiceStateTracker.java | <p>How can I get to know whether SIM is present or not in GsmServiceStateTracker.java file?</p>
| android | [4] |
5,626,239 | 5,626,240 | PHP Automatic Image resizing after upload | <p>What is the standard way to have people upload large image files (say, 20m) but instead of bouncing the user on a set size limit, simply resize it to fit the constraints?</p>
<p>This is from just an HTML file upload to a PHP script. Thanks!</p>
| php | [2] |
1,267,984 | 1,267,985 | Catch a connection failure? | <p>I am using SAXParserFactory and XML reader for fetching from the API.But sometimes when the internet connection goes down,it is getting stuck and application is getting crashed.I am not so good in the concept of exception handling and all. Can anyone help me in finding a solution.I want that operation to be stopped and want to show a custom message, when connection fails.
Please help.
Very urgent..</p>
| android | [4] |
1,029,022 | 1,029,023 | raise an event of a class from a different class in c# | <p>I have class EventContainer.cs which contains an event say </p>
<p><code>public event EventHandler AfterSearch;</code></p>
<p>I have another class EventRaiser.cs. I want to raise (and not handle) the above said event from this class. The raised event will in turn call the handler of the event in the EventContainer class. Something like this (This is obviously not correct)</p>
<pre><code>EventContainer obj = new EventContainer();
RaiseEvent(obj.AfterSearch);
</code></pre>
| c# | [0] |
2,651,777 | 2,651,778 | SMS Delivery Report in Android | <p>I want to get SMS delivery report I am trying many examples but, one flow not displaying delivery report like if my balance is 0 when SMS sending in my code is not displaying SMS delivery report failed otherwise shows report like no service etc.. I want to find SMS sending failed delivery report when my balance is 0.</p>
<p>Help me with any code!</p>
<p>Thanks in Advance!</p>
| android | [4] |
3,991,149 | 3,991,150 | Policies in functions/methods | <p>Out of curiosity (I just want to know how is it done in C#) how are you supplying a policy to a function/method? For example, if I have a function which sorts in C++ I can do something like this: </p>
<pre><code>std::sort(v.begin(),v.end(), Comparator<char>());
</code></pre>
<p>where v is a vector, v.begin is beginning of it and v.end end of this vector and this curious Comparator() is a policy which specifies on what critceria is this vector to be sorted. It can be for example that sorting will be done ignoring case of a char etc etc.<br>
How would you do the same in C#?</p>
| c# | [0] |
4,747,395 | 4,747,396 | How to use dispatchTouchEvent? | <p>How can I call an <code>onTouch</code> method programmatically by dispatching a fake touch event?</p>
| android | [4] |
59,568 | 59,569 | Can you intercept the long press on menu? | <p>I'm using what should be pretty simple code, but it just doesn't want to work. Does the OS block intercepting this?</p>
<pre><code>@Override
public boolean onKeyLongPress(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_MENU)
{
longOptionPress = true;
openOptionsMenu();
return true;
}
return super.onKeyLongPress(keyCode, event);
}
</code></pre>
| android | [4] |
3,140,436 | 3,140,437 | How to use getSharedPreferences(String, int) in dialogpreference class? | <p>When I tried to use getSharedPreferences(), eclipse gave me the android.Preference.preference.getSharePreferences() one, but not the one from contextWrapper which has 2 arguements. I tried to included the whole name which is android.content.ContextWrapper.getSharedPreferences(null, 0), but still doesn't work, eclipse said cannot make a static reference to a non static one.
Any idea? I don't have any problem calling the one with 2 arguments in other class such as activity though.</p>
<pre><code>public class DialogExPreference extends DialogPreference implements DialogInterface.OnClickListener
{
SharedPreferences settings;
@Override
public void onClick(DialogInterface dialog, int which)
{
if(which==-1)
{
if(!pw1.getText().toString().equals("")&&!pw2.getText().toString().equals(""))
{
if(pw1.getText().toString().equals(pw2.getText().toString()))
{
settings =getSharedPreferences();// android.content.ContextWrapper.getSharedPreferences(null, 0);
Editor editor = settings.edit();
editor.putString("password", pw1.getText().toString());
editor.commit();
Toast.makeText(getContext(), "Password Saved", Toast.LENGTH_SHORT).show();
.....
</code></pre>
| android | [4] |
1,347,021 | 1,347,022 | Help needed tweaking jQuery miniZoomPan | <p>I'm using this zoom script on my site:</p>
<p><a href="http://www.gcmingati.net/wordpress/wp-content/lab/jquery/minizoompan/" rel="nofollow">http://www.gcmingati.net/wordpress/wp-content/lab/jquery/minizoompan/</a></p>
<p>At present, the default setup is that it immediately starts the zoom effect when you hover the image with your mouse. </p>
<p>How can I make it that it needs a click first to activate it? So the zoom only starts on a click event. Is it possible?</p>
<p>Thanks in advance!</p>
| jquery | [5] |
3,542,001 | 3,542,002 | drawing ASCII art in java | <p>hi i would like to draw a square with * as an outline and dot in the middle with size range 4 -20.</p>
<pre><code>*****
*...*
*...*
*...*
*****
</code></pre>
<p>i'm having a trouble to make the height equal with the length.
this is my code, could you please help.. thanks</p>
<pre><code>class Main
{
public static void printSquare( int size )
{
if ( size >= 20 && size >= 4)
{ size = 4; }
int squareLenght = size;
int i = 1;
int p = 1;
if ( p <= size )
{
int t = 1;
while ( t <= squareLenght )
{
System.out.print( "*" );
t = t + 1;
}
}
System.out.println(); // Newline
i = i + 1;
while ( i <= squareLenght )
{
int d = 1;
int s = 1;
if ( s < squareLenght );{
System.out.print( "*" );
s = s + 1;
}
while ( d < size-1 )
{
System.out.print( "." );
d = d + 1;
}
System.out.println( "*" );
i = i + 1;
}
if ( p <= size )
{
int t = 1;
while ( t <= squareLenght )
{
System.out.print( "*" );
t = t + 1;
}
}
System.out.println();
i = i + 1;
}
}
</code></pre>
| java | [1] |
1,303,371 | 1,303,372 | Jquery Bind Keyup issue | <p>I have a text box that will input a figure in %. What i want to do is that as the user typesin his digits, a '%' sign should get appended at the end. so if some one types in 1.23, what he should see is :- 1% -> 1.% -> 1.2% -> 1.23%. This is what I have written</p>
<pre><code>$('#price').bind('keyup',function(){
val1 = $(this).val();
val2 = val1.substr(0,val1.length-1);
$(this).val(val2+'%');
});
</code></pre>
<p>The problem is the cursor comes in after the % sign appended so after 1% if I type '.' the val1 = "1%." and the final result is 1%%. Some help please? If you can tell me how to put the cursor before % or some other solution to the original issue. Thanks a bunch</p>
| jquery | [5] |
2,869,480 | 2,869,481 | In php what is more efficient n-1 < x OR n <= x | <p>What is more efficient</p>
<pre><code>if ($n-1 < $x)
</code></pre>
<p>or</p>
<pre><code>if ($n <= $x)
</code></pre>
<p>Anyone know?</p>
| php | [2] |
1,775,461 | 1,775,462 | What does <- mean in C++? | <p>I was looking around for something else when I stumbled upon <a href="http://stackoverflow.com/questions/8831221/looking-for-a-more-efficient-ifelse">this article</a>. I looked at it blankly. I didn't have any idea how to parse it.</p>
<p>Could someone please explain or point me in the right direction?</p>
| c++ | [6] |
4,515,819 | 4,515,820 | subdomain with rewriteModule | <p>hi
i'm using this rule for rewriting subdomain</p>
<p>
</p>
<p>and i'm corrected host file to</p>
<p>127.0.0.1 domain.net</p>
<p>when user typed news.domain.net/default.aspx it must return domain.net/news/default.aspx but browser showed Address not found.</p>
<p>how do i?</p>
<p>please help</p>
<p>thanks all</p>
| asp.net | [9] |
4,332,756 | 4,332,757 | Get rid of the strip line under the TabWidget | <p>I'm using Android 3.0.</p>
<p>I've created <code>TabHost</code> with <code>TabWidget</code> in my layout and I add the tabs during runtime.
I want to get rid of the blue line under the <code>TabWidget</code> which also indicates on the active tab. I've tried to set the strip to disabled but it didn't help.
How can I do it?</p>
<p>Thanks</p>
| android | [4] |
3,606,588 | 3,606,589 | The split() method in Java does not work on a dot (.) | <p>I have prepared a simple code snippet in order to separate the errorneous portion from my web application.</p>
<pre><code>public class Main{
public static void main(String[] args) throws IOException
{
System.out.print("\nEnter a string:->");
BufferedReader br=new BufferedReader(
new InputStreamReader(System.in));
String temp=br.readLine();
String words[]=temp.split(".");
for(int i=0;i<words.length;i++)
{
System.out.println(words[i]+"\n");
}
}
}
</code></pre>
<hr>
<p>I have tested it while building a web application JSF. I just want to know why in the above code temp.split(".") does not work. The statement System.out.println(words[i]+"\n"); displays nothing on the console means that it doesn't go through the loop. When I change the argument of the temp.split() method to other characters, It works just fine as usual. What should be the problem?</p>
| java | [1] |
891,359 | 891,360 | Don't remember the name of a Java case tool where you can wire components | <p>I saw an ads some weeks ago about such a case tool with a free community edition but I don't remember the name.</p>
<p>Does someone knows something like this ?</p>
| java | [1] |
4,193,649 | 4,193,650 | How to create custom search box | <p>I am doing search_bar in my android application, for that i created edit text and button. it will search data whatever we edited in edit text.But giving more attraction to my search_bar i have a idea to include android default search box to my application. i am not sure about the possibility of including default search bar to my application. I searched in google, but i cant get any proper guidance. if any of you guys having idea about this issue please guide me.. </p>
| android | [4] |
1,667,601 | 1,667,602 | Handling a series of named variables of the same type | <p>The following example is bad, because it has code repetition. For example, if we later need to <code>CheckExpirationDate</code> before drinking, we need to add the function call in multiple places. If we need to add <code>charley</code> and <code>stan</code> to the party, the code gets huge quickly.</p>
<pre><code>if (john != designatedDriver)
{
beer.Open();
john.Drink(beer);
}
if (bob != designatedDriver)
{
cider.Open();
bob.Drink(cider);
}
</code></pre>
<p>The solution could be to build an array of these objects. That's really easy if you need to operate one object at a time. For example, if everyone is passing around a single bottle of beer:</p>
<pre><code>beer.Open();
foreach (Dude i in new Dude[] { john, bob })
{
i.Drink(beer);
}
</code></pre>
<p>To rewrite the original example, we can use a <code>KeyValuePair</code>. Not particularly pretty, but well worth it for more than two dudes or if the drinking procedure is long enough (wine tasting).</p>
<pre><code>foreach (KeyValuePair<Dude, Booze> i in KeyValuePair<Dude, Booze>[] {
new KeyValuePair<Dude, Booze>(john, beer),
new KeyValuePair<Dude, Booze>(bob, cider) })
{
if (i.Key != designatedDriver)
{
i.Value.Open();
i.Key.Drink(i.Value);
}
}
</code></pre>
<p><b>But what if we need to operate three or more objects at a time?</b> For example, john drinks beer <i>and</i> eats nachos. We can resort to declaring custom types, but that would make the code dependent on other code somewhere far away. We could put each type in its own array and do a good old <code>for</code> loop and access the objects with indexes, but that would mean creating named arrays (<code>Dude[] dudes = new Dude { john, bob };</code>).</p>
<p>What I'm asking is, <b>is there some fancy C# trick that would let me do this very cleanly and compactly?</b> Anonymous types? Something?</p>
| c# | [0] |
2,625,890 | 2,625,891 | how to resolve c++ warning: multi-character character constant | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/8243360/how-to-resolve-warning-multi-character-character-constant-in-linux-c">How to resolve warning: multi-character character constant in Linux C++</a> </p>
</blockquote>
<p>I am trying to resolve warning: multi-character character constant here but if I use like this I am getting errors. Any suggestions please ?</p>
<pre><code>#if TARGET_OS_W_NT || TARGET_OS_W_CE
//do some thing
</code></pre>
| c++ | [6] |
2,998,420 | 2,998,421 | php script to edit record within 10 minutes from add time | <p>i want a php script for following scenario</p>
<p>when user add particular record then user will be able to edit that record within 10 minutes after adding.</p>
<p>thanks in advance</p>
<p>Girish</p>
| php | [2] |
1,994,187 | 1,994,188 | Grabbing specific months first date and lastdate in PHP | <pre><code>function firstOfMonth() {
return date("m/d/Y", strtotime(date('m').'/01/'.date('Y').' 00:00:00'));
}
function lastOfMonth() {
return date("m/d/Y", strtotime('-1 second',strtotime('+1 month',strtotime(date('m').'/01/'.date('Y').' 00:00:00'))));
}
</code></pre>
<p>is what i have to get the current month's first day date and last day date.</p>
<p>Now i wish to change it alittle, so in both functions they have a param with $month, where $month holds the number of the month I would like to get the first date and last date from.</p>
<p>Example if i do firstOfMonth(1), I would like it to return 2012-01-01 and lastOfMonth(1) it should return 2012-01-31</p>
<p>How can i do this?</p>
| php | [2] |
809,195 | 809,196 | How to remove </li> closing tag and replace with <ul> tag in jquery | <p>I am new guy in jquery. In my workplace, I need to be nested list view dynamically as shown in below.</p>
<pre><code><ul>
<li>
Food
<ul>
<li>Apple</li>
<li>Orange</li>
<\ul>
</li>
<li>
Animals
</li>
</ul>
</code></pre>
<hr>
<p>Now in my code as follows:</p>
<pre><code><ul>
<li>
Food
</li>
<ul><\ul>
<li>Apple</li>
<li>Orange</li>
<li>
Animals
</li>
</ul>
</code></pre>
<p>To be nested structure, I need to remove </li> closing tag and start with to be nested structure. Although, I made web surfing there is no related examples with my problems. Some suggested to use regular expressions with javascript. But it doesn't working. Is there any idea, I am going to appreciate!!!</p>
| jquery | [5] |
3,996,911 | 3,996,912 | Why does this while loop freeze my page? | <pre><code>var f = 5, d;
while (f === 5) d = 2;
alert(d);
</code></pre>
<p>Why does this freeze my page. I thought only when the page is doing a document.write, alert, or console.log inside a while loop (without a incremented value with a limit) it will freeze the page, but not with variables... Do I still have to have a <code>var i = 0; while (i < 5 &&...</code> just to get this to work?</p>
<p>EDIT: I found this in the source-code of google. This while loop doesn't have a number limit but it doesn't freeze the page:</p>
<pre><code>while (a && !(a.getAttribute && (b = a.getAttribute("eid")))) a = a.parentNode;
</code></pre>
| javascript | [3] |
4,202,864 | 4,202,865 | find out which activity started my activity? | <p>i want to find out which activity started my activity in android. I can get the intent that started the activity using "getIntent()" but i am not able to find out which activity started the intent in the first place.</p>
<p>looking forward to your help.
thank you in advance.</p>
| android | [4] |
3,418,585 | 3,418,586 | What are the pitfalls of executing jQuery without $(document).ready();? | <p>Self-explanatory, I hope.</p>
| jquery | [5] |
1,609,472 | 1,609,473 | Dynamic Watermark / On-the-fly Zip Files problem | <p>Before I start, I can post up some code later. I'm in work just now but the problem's really bugging me! Hopefully I can explain it well enough.</p>
<p>I have two functions which work as expected on their own. One of them is displaying a watermark over my photographs. Because my client is fussy and changes things every other day, I decided to dynamically add the watermark when the image is requested.</p>
<p>It works by using my .htaccess file to redirect any requests made to my image directory to go through a watermark.php file. In this file (code to follow), the function picks up the requested image, applies the watermark and then outputs the result and alters the page headers to correspond with that file type.</p>
<p>This works as it should and I'm happy with that.</p>
<p>My other function is creating zip files on-the-fly of specific images (from an array) from this folder. The problem is that because the zip function doesn't go through my watermark.php file, the compressed images don't have the watermark attached.</p>
<p>Hopefully that makes sense. Does anyone have any suggestions on how to fix this? The only thing I've tried is updating the array URLs to go to watermark.php?src=image.jpg to see if that would work (instead of going direct to the image) but the resulting zip file was empty.</p>
<p>Any help / suggestions would be much appreciated :)</p>
| php | [2] |
677,978 | 677,979 | My Array holds previous values too every time i use. | <pre><code>var TransactionObject = {
arr1: [],
arr2: []
};
</code></pre>
<p>My Array holds previous values too every time i use my model class. </p>
<pre><code>var data = update(TransactionObject.arr1);
JsonClient.send(data );
</code></pre>
<p>The first time the array holds some value, and the next time when i make the request... it adds the previous data too... the array is not getting cleared at all. </p>
| javascript | [3] |
5,874,456 | 5,874,457 | Multiple distribution provisioning profile allowed? | <p>What happen when you install multiple distribution provisioning profile on the same system? Can you still code sign your app?
I don't quite understand how the provisioning profile works, can someone explain?</p>
| iphone | [8] |
2,529,678 | 2,529,679 | Pycap not working in script | <p>i m trying to capture ethernet packet using pycap <a href="http://pycap.sourceforge.net/" rel="nofollow">http://pycap.sourceforge.net/</a>. when i use following command on python prompt with root privileges, it is working</p>
<pre><code>>>>import pycap.capture
>>>p = pycap.capture.capture("wlan0")
>>>p.next()
(Ethernet(type=0x608, 00:1b:b1:46:53:5d -> ff:ff:ff:ff:ff:ff), ARP(op=0x1, protocol=0x800, 00:1b:b1:46:53:5d (192.16.68.10) -> 00:00:00:00:00:00 (192.16.110.39)), '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', 1307898356.222398)
</code></pre>
<p>But if i run these commands as a script, i m getting following error</p>
<pre><code>>>>sudo python pycap.py
Traceback (most recent call last):
File "pycap.py", line 2, in <module>
from pycap import *
File "/home/nikhil/Code/Python/pycap.py", line 5, in <module>
p = capture.capture(device)
NameError: name 'capture' is not defined
</code></pre>
<p>Any suggestions?
pycap <a href="http://pycap.sourceforge.net/" rel="nofollow">http://pycap.sourceforge.net/</a> says it is requires python2.3 and im using python2.6. Is that a problem?</p>
| python | [7] |
2,249,950 | 2,249,951 | Move closing </a> tag | <p>I have a pdf link with the filesize as follows...</p>
<pre><code><a class="pdf-link" href="some-pdf.pdf">Some PDF</a> <span class="filesize">(PDF 100kb)</span>
</code></pre>
<p>The link is generated by our CMS and for our mobile site the span needs to sit within the link.</p>
<p>Would anyone know of a way to move the closing <code></a></code> tag to the end of the span, preferably with jQuery? </p>
<pre><code><a class="pdf-link" href="some-pdf.pdf">Some PDF <span class="filesize">(PDF 100kb)</span></a>
</code></pre>
<p>Any help would be much appreciated.</p>
| jquery | [5] |
47,961 | 47,962 | Ajax class in Javascript not working | <p>I am trying to create my own version of the ajax method in Jquery to see how it works:</p>
<pre><code>function ajax(url, method) {
var self = this;
this.xhr = new XMLHttpRequest();
this.xhr.onreadystate = function() {
self.xhrHandler();
}
this.xhr.open(method, url, true);
this.xhr.send();
}
ajax.prototype.xhrHandler = function() {
if (this.xhr.readyState == 4) {
console.log(this.xhr.responseText);
}
console.log("test");
}
</code></pre>
<p>It never goes into the xhrHandler function, though, since it never prints out "test". What is going on?</p>
<p>Edit: Here is a usage example: <code>var ex = new ajax("www.fake.com/api/item/1/", "GET");</code></p>
| javascript | [3] |
5,549,874 | 5,549,875 | How to get string format link url .html in array using preg_match? | <p>I have a sample code:</p>
<pre><code>$array = array(
1 => "tag/gomobi.html",
2 => "game.html",
3 => "game.php",
4 => "game.html",
5 => "game/game-mobile/feed.html"
);
foreach ($array as $url) {
if(preg_match('/^((.*)\.html)(.*?)$/', $url, $matches)) {
echo $matches[1].'<br />';
}
}
</code></pre>
<p>But result can't remove value same (game.html)</p>
<pre><code>tag/gomobi.html
game.html
game.html
game/game-mobile/feed.html
</code></pre>
<p>How to fix it, with result is:</p>
<pre><code>tag/gomobi.html
game.html
game/game-mobile/feed.html
</code></pre>
| php | [2] |
6,008,273 | 6,008,274 | Downloading a folder through with FTP using PHP | <p>How can i donwload a folder from a remote host using FTP And PHP?</p>
<p>I have username and password and the folder to donwload...</p>
<p>copy()?</p>
<p>Let me know, thanks!</p>
| php | [2] |
4,230,271 | 4,230,272 | Jquery why would .onfocus or .select bring focus on an adjacent selector | <p>What I wish to happen - when I tab away from the second to last tab in the tabindex I want to check to see if the submit button is disabled (which is it until all validations successful). If is is disabled I do not want to proceed to the next tabindex (which looses all focus as the button is disabled). In stead I want to return to the first tabindex.</p>
<p>I have tried doing this by cycling through the tabindex and selecting when tabs index = 1.
I have also tried simply setting focus on the named selector.</p>
<p>In each case the hightlighted field is NOT the first in the form it is the second. Ditto if I try to redirect to the second field the third field highlights.</p>
<p>This makes no sense. And is doubling confusing as I set focus elsewhere on other fields without an issue.</p>
<p>Could anyone suggest a circumstance where this could happen.</p>
<pre><code> switch(event.which){
......
case 9:
kp_Count++;
// skip create button if disabled
if ($(".form_Submit").attr("disabled") == "disabled"){
alert("in");
$("#first_Name").focus();
};
<form id="create_Client" action="process_Client_Create.php" method="post">
<div class="form_Col_1">
<div class="form_Row">
<a class="field_Label_Left">First Name:</a> <input class="field_Input_Left" id="first_Name" tabindex="1" type="text" name="first_Name"/><br />
</div>
<div class="form_Row">
<a class="field_Label_Left">Middle Name:</a> <input class="field_Input_Left" id="middle_Name" tabindex="2" type="text" name="middle_Name"/><br />
</div>
</code></pre>
<p>P:S I have to step out until this afternoon. But I will look in later. Many Thanks </p>
| jquery | [5] |
2,402,011 | 2,402,012 | Add strings in an array - Javascript | <p>I have an array of text:</p>
<pre><code>var text=new Array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s");
</code></pre>
<p>I would like to add the elements in the array according to a set number and then store these in a new array. For example, if I pick 3, then the resulting strings in the new array (terms) would be: "a b c","d e f", "g h i" etc</p>
<p>I looked at Join and I can't get this to work - it seems to only be able to add the entire array together. I'm guessing I need to use a nested loop, but I can't seem to get this to work. Here's my attempt:</p>
<pre><code>//Outer loop
for (i=0; i < text.length; i++) {
//Inner loop
for (j=i; j < i+$numberWords; j++) {
newWord=text[j];
newPhrase=newPhrase+" "+newWord;
}
terms.push(newPhrase);
i=i+$numberWords;
}
</code></pre>
<p>Thanks in advance.</p>
| javascript | [3] |
4,980,789 | 4,980,790 | Missing System.Web.UI and System.Web.Security | <p>I can't compile a project because the namespaces System.Web.UI and System.Web.Security are missing. I can only see System.Web.ApplicationServices, System.Web.Mvc and System.Web.Services when I do add references. Where do I download the missing namespaces?</p>
| c# | [0] |
1,313,202 | 1,313,203 | Help me to resolve this error | <p>I am trying to create a activity for displaying a menu on the emulator screen, by adding this code in my AndroidViews.java file</p>
<p><strong>AndroidViews.java</strong></p>
<pre><code>@Override
public boolean onCreateOptionMenu(Menu menu)
{
super.onCreateOptionsMenu(menu);
menu.add(0,1, Menu.NONE,"M1");
menu.add(0,2,Menu.NONE, "Button");
menu.add(0,3,Menu.NONE, "CheckBox");
return true;
}
</code></pre>
<p>i am trying to Override the onCreateOptionMenu method of activity class but whenever I have write a Override keyword with the method it will produced an error i.e.
<strong>The method onCreateOptionMenu(Menu) of type AndroidViewsActivity must override or implement a supertype method</strong></p>
<p>Plz help me out as soon as possible</p>
| android | [4] |
1,480,440 | 1,480,441 | javascript: for loop | <p>Why this for loop doesnt work?</p>
<p>javascript:</p>
<pre><code>function create(){
var newDiv = document.createElement("input");
var character = "piyush";
var i =0;
newDiv.type = "text";
newDiv.style.background = "red";
newDiv.style.width ="20px";
newDiv.style.height ="20px";
for( i =0; i< character.length ; i++)
{
document.getElementById("tryingin").appendChild(newDiv);
}
}
</code></pre>
<p>html:</p>
<pre><code><div id="tryingin" onMouseOut="create()" style="width:200px; height:200px; background-color:black"> </div>
</code></pre>
<p>now when i alert something in the for loop . i see the alert box 6 times one after the other(as character.length == 6). but why i dont see 6 textboxes appended in the division?
And what should be the correct code to append all 6 textboxes all at once.</p>
<p>Help appreciated.
Regards!</p>
| javascript | [3] |
2,872,641 | 2,872,642 | ASP.NETand TFS: Getting TF30076 Error | <p>i'm developing an ASP.NET application to deal with TFS server programmatically to list all TFS projects and give the ability to add work items to any TFS project. if i run the application locally using visual studio local host --> every this is running as required.</p>
<p>if i host the application on my iis , i face the following error :</p>
<p>TF30076: The server name {tfsServerName} provided does not correspond to a server URI that can be found. Confirm that the server name is correct.</p>
<p>i don't know what is the difference between the two cases.</p>
<p>any help please ????? </p>
| asp.net | [9] |
1,650,158 | 1,650,159 | How to poistion edittext in program in android? | <p>I am dynamically creating an Editext in my code. i want to position it in my x and y position in my code itself in an absolute layout.
can anyone help me to do this.</p>
| android | [4] |
4,336,190 | 4,336,191 | Hankaku to Zenkaku and vice versa in Java | <p>Is there any utility available in Java for converting between Hankaku characters and Zenkaku characters i.e. Japanese Half Width kana and Full Width kana? Or is there an algorithm or approach available that could be implemented for this?</p>
| java | [1] |
2,769,630 | 2,769,631 | Intialize static final variable | <p>I was wondering, what is there any different, on various ways to initialize static final variable?</p>
<pre><code>private static final int i = 100;
</code></pre>
<p>or</p>
<pre><code>private static final int i;
static {
i = 100;
}
</code></pre>
<p>Is there any different among the two?</p>
| java | [1] |
485,543 | 485,544 | jQuery - Loading Thumbnails | <p>basically I have thumbnails at the bottom of the page and one large image. I want to be able to hover over the thumbnails and have the source of the thumbnail replace that of the big image so the thumbnail takes its place.</p>
<p>Please someone help!! I need to get this finished asap, is there any other info I should provide?!</p>
<p>This is the code I am using:</p>
<pre><code>jQuery('.image-rollover').hover(function() {
var src = $(this).attr("src").match(/[^\.]+/);
jQuery('.replace img').replace("src", src);
});
</code></pre>
| jquery | [5] |
2,545,949 | 2,545,950 | Specific Double Tap | <p>I have zoomable image and I'm using <code>ScaleGestureDetector.SimpleOnScaleGestureListener</code>. I need to implement following items:</p>
<ol>
<li>On Single Tap appear Toast with information about picture. </li>
<li>On Double Tap image is zooming.</li>
</ol>
<p>I have some issue. Before Double Tap always is Single Tap and picture is zooming, but appear Toast. Is there any way to avoid Single Tap? I dont have enough savvy to solve this problem.</p>
<p><strong>P.S.</strong> I <strong>can't use <code>OnDoubleTapListener</code></strong> because use <code>ScaleGestureDetector.SimpleOnScaleGestureListener</code>.</p>
<p><strong>UPD</strong></p>
<pre><code>case MotionEvent.ACTION_UP:
firstTime = System.currentTimeMillis();
if (Math.abs(firstTime-secondTime) < 300L) {
// scale my matrix
---//---
DONE = true; //this flag symbolize, that toast doesn't appear (false - appears)
}
else if (!DONE) {
// making toast
}
secondTime = firstTime;
break;
</code></pre>
<p>When DoubleTap is enable image scaled but appears toast</p>
| android | [4] |
20,838 | 20,839 | jQuery text match | <p>I have an anchor tag with text and I want to check if the given var matches the string exactly.</p>
<p>This works, but I would like to use something other than contains, since it will match two elements if the contain the given string. I want it to match exactly.</p>
<p>Any ideas ?</p>
<pre><code>function test(submenu){
$('a:contains("' + submenu + '")', 'ul.subMenu li').css('font-weight', 'bold');
}
</code></pre>
| jquery | [5] |
3,394,297 | 3,394,298 | how to retrieve the value from text field? | <p>How to retrieve the value from text field?
And how to concanate the value in jquery?</p>
| jquery | [5] |
846,231 | 846,232 | Creating a large background and moving it with your finger | <p>I am designing a Game and have a large background. The background it a lot bigger than the phone display so the user will only have a small "View" of the background. They will be able to move around by scrolling with their finger. </p>
<p>How do i go about this?</p>
| android | [4] |
4,036,108 | 4,036,109 | Clear all array list data | <p>Why doesn't the code below clear all array list data?</p>
<pre><code> Console.WriteLine("Before cleaning:" + Convert.ToString(ID.Count));
//ID.Count = 20
for (int i = 0; i < ID.Count; i++)
{
ID.RemoveAt(i);
}
Console.WriteLine("After cleaning:" + Convert.ToString(ID.Count));
//ID.Count = 10
</code></pre>
<p>Why is 10 printed to the screen?</p>
<p>Maybe there is another special function, which deletes everything? </p>
| c# | [0] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.