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
2,701,801
2,701,802
TO initiate Python shell
<p>You can use subprocess.call("/usr/bin/python") to open Python shell within a piece of Python code. Now my question is is it possible to predefine some variables/functions before initialization of this shell? In other words, inside Python code, I can define a bunch of useful variables and functions and I want them to be available in the Python shell opened later by subprocess call. It is useful in the sense that sometimes you want a customized Python shell to test your environment. </p>
python
[7]
2,682,050
2,682,051
Javascript counter issue
<p>I'm working now with site with paralaxx effect. I catch mouse position from window. If mouse on top window.InnerHeight / 100 * 20 i will get window.mouseposition = "top" and window.mouseposition = "bottom". </p> <p>I have issue in function i get broken counter.</p> <p>But when dom is loaded, i have var currentSlide = 0; and i have event:</p> <pre><code> &lt;div id="slide1&gt;&lt;/div&gt; &lt;div id="slide2&gt;&lt;/div&gt; &lt;div id="slide3&gt;&lt;/div&gt; &lt;div id="slide4&gt;&lt;/div&gt; view.on('click',function(){ if(window.mouseposition == "up" &amp;&amp; currentSlide &lt;= slide.length &amp;&amp; currentSlide != 0){ goToByAttr(currentSlide -=1); } if(window.mouseposition == "bottom" &amp;&amp; currentSlide &lt; slide.length){ goToByAttr(currentSlide +=1); } }); function goToByAttr(dataslide) { console.log(currentSlide); var element2 = document.getElementById("slide"+dataslide); view.stop().animate({ scrollTop: getOffsetSum(element2).top }, 1000, 'easeInOutQuint'); currentSlide = dataslide; return currentSlide } </code></pre> <p>When i click in the first time on the bottom, browser returns 1,2. And it scrolls to slide 2, but need 1. But browser must return only 1; and then 2.</p> <p>If i click on the top from 2, browser returns 1,0; And it scrolls to slide 0, but need 1.</p> <p>Please help, why i get it?</p>
javascript
[3]
2,849,747
2,849,748
Why is mktime() returning unexpected results?
<pre><code>$date['start'] = date("o-m-d", mktime(0, 0, 0, 1, 1, 2010)); $date['end'] = date("o-m-d", mktime(0, 0, 0, 2, 1, 2010)); </code></pre> <p>Each element contains <code>2009-01-01</code>, <code>2010-02-01</code> respectively. Why is the first element returning 2009, when it has been specified as 2010?</p> <p>What I am trying to achieve is to specify a date I can use in a MySQL query, like:</p> <p><code>SELECT subject, created_on FROM issues WHERE created_on BETWEEN 2010-01-01 AND 2010-02-01 ORDER BY created_on</code></p>
php
[2]
1,292,683
1,292,684
How can I provide an iPhone app that will be integrated into a customer's project without providing the source code?
<p>I would like to provide my client a native iPhone application module that he could integrate within his own iPhone application.</p> <p>I don't want to provide the source code.</p> <p>How can I achieve this?</p>
iphone
[8]
4,724,521
4,724,522
how to i input a sentence so that the program will recognize the sentence as a single word?
<p>lets say i input : 'dog is mammal'</p> <p>i would like to search for this sentence in a text document. How do i do this in java ?</p> <pre><code> System.out.println("Please enter the query :"); Scanner scan2 = new Scanner(System.in); String word2 = scan2.nextLine(); String[] array2 = word2.split(" "); </code></pre> <p>this code snippet accepts the string 'dog is mammal' and process each tokens separately.</p> <p>For example : 'dog is mammal'</p> <p>dog</p> <p>></p> <p>></p> <p>is</p> <p>></p> <p>></p> <p>mammal</p> <p>></p> <p>></p> <p>i would like to process the input as </p> <p>dog is mammal</p> <p>></p> <p>></p> <p>I doesnt want it to process it separately. I wanted it to process it as a single string and look for matches. Can anyone let me know where i am lacking ? </p>
java
[1]
5,233,869
5,233,870
how can I customize and change the background color of spinner in android?
<p>I want to change the background color of spinner and customize spinner. When I used this code in xml android:background="#000000" the color changed but the arrow on the spinner disappears. How can I cuztomize spinner and change the background color without disappearing the arrow?</p>
android
[4]
5,857,912
5,857,913
How to know if no object has focus?
<p>How do I find out if no object has focus?</p> <p>Example scenario: The page reloads and I run a function which will say if any object has focus or no one has it.</p> <p>Just asking here because google didn't help.</p>
javascript
[3]
1,025,893
1,025,894
Can I shrink this code with an array or loop?
<p>Forgive me, I hope this question isn't too obvious, I'm a javascript noob.</p> <p>I have javascript code that takes numbers from an xml sheet and displays them in td elements on an html page. It works but I think it could be condensed into an array or a loop to be more efficient.</p> <p>Is there a better way to write this code?</p> <pre><code>window.onload=function displayPrices() { twentyFourK=(x[i].getElementsByTagName("twentyFourK")[0].childNodes[0].nodeValue); document.getElementById("twentyFourK").innerHTML=toCurrency(twentyFourK); oneOzGold=(x[i].getElementsByTagName("oneOzGold")[0].childNodes[0].nodeValue); document.getElementById("oneOzGold").innerHTML=toCurrency(oneOzGold); fiveOzGold=(x[i].getElementsByTagName("fiveOzGold")[0].childNodes[0].nodeValue); document.getElementById("fiveOzGold").innerHTML=toCurrency(fiveOzGold); tenOzGold=(x[i].getElementsByTagName("tenOzGold")[0].childNodes[0].nodeValue); document.getElementById("tenOzGold").innerHTML=toCurrency(tenOzGold); oneKiloGold=(x[i].getElementsByTagName("oneKiloGold")[0].childNodes[0].nodeValue); document.getElementById("oneKiloGold").innerHTML=toCurrency(oneKiloGold); //etc. } </code></pre>
javascript
[3]
359,857
359,858
This function is only working sometimes
<pre><code>function getYoutubeVideoId($url) { $urlParts = parse_url($url); if($urlParts === false) return false; if(isset($urlParts['host']) &amp;&amp; strtolower($urlParts['host']) === 'youtu.be') return ltrim($urlParts['path'], '/'); if(isset($urlParts['query'])) { parse_str($urlParts['query'], $queryParts); if(isset($queryParts['v'])) return $queryParts['v']; } return false; } </code></pre> <p>This function works great.. unless you use <code>youtu.be/*</code> without <code>http://</code></p> <p>Why does it not work if it is just <code>youtu.be</code> or <code>www.youtu.be</code> ?</p>
php
[2]
4,599,236
4,599,237
Is it good practice to require the type in a class template to respond to a certain func?
<p>The std lib has types in class templates that requires the type to override certain OPERATORS, for exmple, the type we use in std::map requires the type to support the &lt; operator.</p> <p>But is it good to require certain FUNCTIONS? Consider this silly example</p> <pre><code>template &lt;typename T&gt; struct Foo { T t; Foo() { t.push_back(0); } }; int main() { Foo&lt;std::vector&lt;int&gt;&gt; foo; return 0; } </code></pre> <p>there i've created a class template Foo and it's type needs to have a push_back member func. Is this design acceptable/common to c++ coders?</p>
c++
[6]
2,613,762
2,613,763
Content Script cross domain or message passing
<p>I am writing a javascript extention that modifies a website. The extention adds a button to the website, and when clicked it modifies the page content. My script has to send cross domain xmlhttprequests to websiteB, and gets permissions upon installation to do so. </p> <p>My problem is that the code that runs in the content scope of the website that I am modifying does not have permission to do cross domain requests, because it is within a content scope of the webpage. Nor can I easily pass variables between my main extention code and the code that runs upon the button click on the page.</p> <p>These are the relevant parts of my code:</p> <pre><code> // ==UserScript== // @include http://www.WebsiteB.com/* // @match http://www.WebsiteB.com/* // ==/UserScript== var a = 1; button.innerHTML = '&lt;a href="javascript:void(0)" onclick="myFunc();"&gt;clickMe&lt;/a&gt;'; menu.appendChild(button); contentEval(function() { myFunc = function() { //a is undefined //this part does not have cross domain request permission }; } </code></pre> <p>I use contentEval taken from <a href="http://wiki.greasespot.net/Content_Script_Injection" rel="nofollow">http://wiki.greasespot.net/Content_Script_Injection</a> to get the relevant code to be able to interact with the page my script is running on. Without it, I would not be able to call myFunc from a button on the website. variables can not be transferred from the main code area to myFunc() by passing them directly using myFunc(a) either. myFunc(1) works, but does not suit my needs.</p> <p>It's possible that I am going about things the wrong way. If so, please enlighten me.</p> <p>Is there a way to have cross domain permissions from the code that interacts with the web page? If not, what should I use to do message passing from the main code area to the content script of the page?</p>
javascript
[3]
2,445,739
2,445,740
Calling an Async function multiple times
<p>I have an Async function</p> <pre><code>function AsyncFunc(args){ //does some async work here } </code></pre> <p>then I call this function multiple times in a <code>for</code> loop:</p> <pre><code>for(var i=0; i&lt;10; i++) { AsyncFunc(i); } </code></pre> <p>Does this create multiple copies of the <code>AsyncFunc</code>? or are the local variables defined in <code>AsyncFunc</code> getting overridden by the subsequent calls? </p> <p>EDIT</p> <p>Suppose the <code>AsyncFunc</code> does following:</p> <pre><code>function AsyncFunc(args){ $.get(args.url, function(data){ args.data = data; }); } </code></pre> <p>then I call this function multiple times in a for loop:</p> <pre><code>for(var i=0; i&lt;10; i++) { AsyncFunc(args_object_with_a_different_url); } </code></pre> <p>Now would <code>data</code> go into their corresponding args object? In other words, would the callback attach to the copy of the function in which the ajax request was initiated?</p>
javascript
[3]
5,445,151
5,445,152
how do I send a line through the server in a loop?
<pre><code>Socket s1=new Socket("localhost",3001); System.out.println("Client process"); byte b[]=new byte[150]; int n=4; BufferedReader BR=new BufferedReader(new InputStreamReader(s1.getInputStream())); String str=new String(); while((str=BR.readLine())!=null) { System.out.println(); System.out.println(str); } s1.close(); </code></pre> <p>In the above code I'm trying to read a line from server and print that line on client machine.But the client couldn't read a line until the server is finished writing all lines and closed.Please help me how to read a line from server at a time.</p>
java
[1]
5,161,444
5,161,445
changing background of link when clicked using jquery
<p>I have 4 links with background color that i need to be changed when i click , i use this code to change the background :</p> <p>jquery :</p> <pre><code>$(document).ready(function() { $('#content_area').load($('.pm_class:first').attr('href')); $('.pm_class').click(function() { var href = $(this).attr('href'); $(this).css('background-color', '#3B581E'); $(this).css('color', '#fff'); $('#content_area').hide().load(href).fadeIn('normal'); return false; }); }); </code></pre> <p>The issue is , when i click a different link the css in my jquery still apply to the previous link i clicked along with the second one , i need the first to return to the original state as shown in the image below , i need it to return back to be like the "send message" and "archive" links :</p> <p><a href="http://www.flickr.com/photos/wfareed/6707380979/" rel="nofollow">jqeury issue</a></p>
jquery
[5]
449,318
449,319
Issue in Calling Service
<p>Here is my service class</p> <pre><code> import android.app.Service; import android.content.Intent; import android.os.IBinder; import android.util.Log; public class Communicationservice extends Service { @Override public IBinder onBind(Intent intent) { // TODO Auto-generated method stub return null; } @Override public void onCreate() { super.onCreate(); Log.d("I AM Service","Service Created"); } @Override public void onStart(Intent intent, int startId) { // TODO Auto-generated method stub super.onStart(intent, startId); } } Here is my Main Activity import android.os.Bundle; import android.app.Activity; import android.content.Intent; import android.util.Log; import android.view.Menu; public class MainActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Log.d("flow","1"); Intent in = new Intent("com.yal.Communication.Communicationservice"); this.startService(in); //startService(new Intent(MainActivity.this,Communicationservice.class)); Log.d("flow","2"); } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.activity_main, menu); return true; } } </code></pre> <p>Here is Mainfest.xml</p> <pre><code>&lt;application android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" &gt; &lt;activity &gt; ... &lt;/activity&gt; &lt;service android:enabled="true" android:name="com.yal.Communication.Communicationservice"&gt;&lt;/service&gt; &lt;/application&gt; </code></pre> <p>Error </p> <pre><code>11-02 16:34:17.939: D/flow(1390): 1 11-02 16:34:17.939: W/ActivityManager(92): Unable to start service Intent { act=com.yal.Communication.Communicationservice }: not found 11-02 16:34:17.939: D/flow(1390): 2 </code></pre>
android
[4]
1,051,045
1,051,046
C# array within a struct
<p>Want to do this: (EDIT: bad sample code, ignore and skip below)</p> <pre><code>struct RECORD { char[] name = new char[16]; int dt1; } struct BLOCK { char[] version = new char[4]; int field1; int field2; RECORD[] records = new RECORD[15]; char[] filler1 = new char[24]; } </code></pre> <p>But being unable to declare array sizes in struct, how do I reconfigure this?</p> <p>EDIT: The reason for the layout is I'm using BinaryReader to read a file written with C structs. Using BinaryReader, and a C# struct union (FieldOffset(0)), I'm wanting to load the header as a byte array, then read it as it was intended originally.</p> <pre><code>[StructLayout(LayoutKind.Sequential)] unsafe struct headerLayout { [FieldOffset(0)] char[] version = new char[4]; int fileOsn; int fileDsn; // and other fields, some with arrays of simple types } [StructLayout(LayoutKind.Explicit)] struct headerUnion // 2048 bytes in header { [FieldOffset(0)] public byte[] headerBytes; // for BinaryReader [FieldOffset(0)] public headerLayout header; // for field recognition } </code></pre>
c#
[0]
2,921,404
2,921,405
how to get all primitive type of an object
<p>I wanna have all properties of an object which have primitive type, and if the object has a relation to another class , I wanna have the primitive properties of this another class too</p> <p>the problem is if entity A has entity B and B has A, what can I do</p> <p>in simple case by using reflection I can get first level Primitive properties but, I cant go into entity B and again get primitive properties of A,, a loop would be created,, what is ur offer?</p> <pre><code>public class A { public string Name{get;set;} public B B{get;set;} } public class B { public string Category{get;set;} public A A{get;set;} } </code></pre>
c#
[0]
3,799,147
3,799,148
PHP to pseudocode?
<p>Is there a tool for converting PHP source to pseudocode automatically?</p> <p>I implemented some algorithm and i want to have its standard independent-language pseudocode. please help me to find the tool,if any.</p> <p>Edit: </p> <p>for example, the PHP source is:</p> <pre><code>$A=array('b'); array_unshift($A,'a'); print_r($A); </code></pre> <p>and its pseudocode is such as:</p> <pre><code>Define array A with first element 'b' Prepend string 'a' to the beginning of array A Print all elements of array A to output </code></pre>
php
[2]
5,947,433
5,947,434
Making a listadapter that supports integers
<p>im trying to implement a listAdapter that supports integer Arraylists by extending the baseAdapter, when initialize the activity my app crashes. Since im new to android i was wondering if anybody could spot something wrong with my implementation</p> <pre><code>package com.test.testapp; import java.util.ArrayList; import com.test.testapp.R; import android.content.Context; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.TextView; public class myListAdapterIntegers extends BaseAdapter { ArrayList&lt;Integer&gt; arrayIntList = new ArrayList&lt;Integer&gt;(); Context context; myListAdapterIntegers(Context c, ArrayList&lt;Integer&gt; myListAdapterIntegers) { this.arrayIntList = myListAdapterIntegers; this.context = c; } @Override public int getCount() { return arrayIntList.size(); } @Override public Object getItem(int location) { return arrayIntList.get(location); } @Override public long getItemId(int position) { return position; } @Override public View getView(int position, View convertView, ViewGroup parent) { View v = View.inflate(context, R.layout.entry_row_int, null); int value = arrayIntList.get(position); TextView monthTextView = (TextView) v.findViewById(R.id.text_row_int); monthTextView.setText(value); return v; } } </code></pre>
android
[4]
1,303,316
1,303,317
How to access to given element in Json
<p>I am new to Json. please tell me how to access following element. this is my Json </p> <pre><code>var data = {"student":[{"fname":"mad", "sname":"cha"}, {"fname":"sun", "sname":"ban"}, {"fname":"sha", "sname":"kiri"}]}; </code></pre> <p>so how I access to the <code>"mad"</code>value.</p> <p>actually this is what I trying to do</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;&lt;/title&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt; &lt;script&gt; function click_me(){ var data = {"student":[{"fname":"mad", "sname":"cha"}, {"fname":"sun", "sname":"ban"}, {"fname":"sha", "sname":"kiri"}]}; localStorage.setItem('my_name',data); alert('OK'); } function show_me(){ var x = localStorage.getItem('my_name'); x = x.student[0].fname; alert(x); } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;input type="button" name="btn" value="Click" onclick="click_me()"&gt; &lt;input type="button" name="btn" value="show_me" onclick="show_me()"&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
javascript
[3]
3,359,349
3,359,350
Long running PHP methods - how to handle?
<p>Here's my scenario. During signup for my app - i trigger a few PHP method calls that are long running (e.g. get UserFriendLikes, etc using OpenGraph API). </p> <p>I want the methods to run in the background without the user noticing it - and leave the method to complete at its own time. </p> <p>Whats the best way to acheive it? Does just calling longRunningMethod() from the user signup page work - or is there anything else i need to do to ensure that it is not terminated when user navigates to another page, etc?</p>
php
[2]
4,391,276
4,391,277
java.util.NoSuchElementException even though input file has data
<p>I have written this code to find out an output and i am running this using Runtime in a servlet. It shows java.util.NoSuchElementEception even though i have checked that input file has some data:</p> <pre><code>public class Sec1q10 { static int fact(int n) { int p = 1; if (n != 1) { p = n * fact(n - 1); } return p; } public static void main(String args[]) { try { System.out.println("first"); Scanner in = new Scanner(new FileReader("F:/sem5/algorithm/in.txt")); String no = in.next(); int n = Integer.parseInt(no); System.out.println(n); int s = 0; while (n != 0) { s += fact(n); n--; } System.out.println("sum=" + s); String s1 = "" + s + "here"; PrintWriter out; System.out.println(s1); out = new PrintWriter("F:/sem5/algorithm/out.txt"); out.write(s1); System.out.println(s1); } catch (Exception ex) { System.out.println("Exception: " + ex); } } } </code></pre> <p>I even run this on cmd where it is showing the output without any exception but not writing anything in the file F:/sem5/algorithm/out.txt</p>
java
[1]
5,131,011
5,131,012
What's the best way to defer actions after a request in ASP.NET?
<p>I'm writing an ASP.NET application. When a specific kind of request is being handled, I want to schedule a method to be called in a certain number of minutes after the request is handled. The postponed method does not need to communicate with the client that made the original request, it is just intended to do some "housekeeping" work. What is the best way to do this in an ASP.NET context? (It's ok to not fire the event if the application domain dies for some reason).</p>
asp.net
[9]
2,764,110
2,764,111
How to Declare Folder Path?
<p>I have a desktop application using Swing library. Application is running a batch file. So I created a <code>lib</code> folder in main project directory and put batch file in it. To run this, I am showing <code>lib\a.exe</code> to run this. It is working on my laptop. I exported .jar and put lib folder next to it. It is working on my laptop, but not working on some other laptops. How to fix this?</p> <p>Error message is: Windows cannot found <code>lib\a.exe</code>.</p> <pre><code>String command = "cmd /c start lib\\a.exe"; try { Runtime.getRuntime().exec(command); increaseProgressBarValue(); } catch (IOException e) { e.printStackTrace(); } </code></pre>
java
[1]
4,982,425
4,982,426
how to disable/enable group of linkbutton
<p>I need to disable 4-5 linkbuttons when one of the linkbutton is clicked.On one linkbutton click disable a group of linkbutton and when a session turns null enable all the linkbutton back to enable mode.I tried few methods none of it is truly disabling the linkbutton.</p>
asp.net
[9]
2,466,839
2,466,840
What are all of the possible values of the textStatus parameter in the callback function of jQuery .load?
<p>I am utilising the callback function of jQuery's <a href="http://api.jquery.com/load/" rel="nofollow">.load</a> method to run certain code if the <code>textStatus</code> parameter of the <code>.load</code> method is equal to a certain string.</p> <p><strong>e.g. I have</strong></p> <pre><code>jQuery("#myContainer").load('/seperate-file-with-content.asp', function(responseText, textStatus, xhr){ if (textStatus === "error" || responseText.length &lt;= 0) { //file failed to load i.e. textStatus == error //or file loaded but has no content } else { //file loaded successfully i.e. textStatus == success } }); </code></pre> <p>But i'm worried that the <code>else</code> part of the <code>if</code> statement may catch other non expected <code>textStatus</code> values that aren't equal to <code>success</code>.</p> <p><strong>Are there any other possible values to textStatus, other than <code>error</code> and <code>success</code> ?</strong></p> <p><strong>EDIT/UPDATE:</strong> As I now believe that <code>.load</code> is based on <code>.ajax</code>, the answers in the following question may be of use for anyone else with a similar question:- <a href="http://stackoverflow.com/questions/3461491/in-jquerys-ajax-success-callback-will-textstatus-ever-not-be-success?rq=1">In jQuery&#39;s ajax success callback, will textStatus ever not be &quot;success&quot;?</a></p>
jquery
[5]
4,723,697
4,723,698
.net windows service
<p>I have created my c# console application as windows service and installed the service in remote server which is 32 bit machine and has 2GB RAM. To this server application many clients are connected and gets the data from server. The problem is sometimes the server machine is down and unable to access the data, that time we need to restart the server every time.I have not able to identify where exactly the problem is. When i was checking the evenlogs in server machine i found the below exception,</p> <p>source .net 2.0 runtime error.</p> <p>EventType clr20r3, P1 myapplication.exe, P2 1.3.2.1, P3 4cb724a3, P4 mscorlib, P5 2.0.0.0, P6 4be90358, P7 1947, P8 7, P9 system.outofmemoryexception, P10 NIL.</p> <p>I have googled a lot, but unable to find exact reason. I am using HTTPSERVER.MVC (opensource) for url communication. To create service below code is added in the main function.</p> <pre><code> ServiceBase[] ServicesToRun; ServicesToRun = new ServiceBase[] { new TouchService() }; ServiceBase.Run(ServicesToRun); </code></pre> <p>Please some one help me out. Thanks in advance</p>
c#
[0]
3,522,482
3,522,483
How to compare two dates in php and echo newer one?
<p><strong>How to compare two dates in php and echo newer one?</strong></p> <p>My dates are in the following format: <code>date("F j, Y, g:i a");</code> which give us <code>August 12, 2011, 9:45 am</code>.</p> <p>My dates are as follow:</p> <ul> <li>date 1 <code>$created</code></li> <li>date 2 <code>$updated</code> / if no updated have been made value is <code>0000-00-00 00:00:00</code></li> </ul> <p>Any suggestion much appreciated. </p>
php
[2]
3,894,577
3,894,578
Target div with jQuery
<p>I have modified my code to streamline it a bit better. I need to be able to hide "old" span and show "new" one when "change" is clicked. I tried using siblings() but it does not appear to work. Am I missing something here:</p> <pre><code>$(".new").hide(); $('.change').click(function() { $(".new").hide(); $(this).siblings(".old").hide(); $(this).siblings(".new").show(); }); &lt;div id="container"&gt; &lt;div&gt; &lt;div class="switches"&gt; &lt;span class="change"&gt;switch&lt;/span&gt; &lt;span class="go"&gt;go&lt;/span&gt; &lt;/div&gt; &lt;span class="old"&gt;old content&lt;/span&gt; &lt;span class="new"&gt;new content&lt;/span&gt; &lt;/div&gt; &lt;div&gt; &lt;span class="change"&gt;switch&lt;/span&gt; &lt;span class="old"&gt;old content&lt;/span&gt; &lt;span class="new"&gt;new content&lt;/span&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>Thanks.</p> <hr> <p>UPDATE:</p> <p>Please note that I have added another level of depth for my triggers placing it inside</p> <pre><code>&lt;div class="switches"&gt; </code></pre> <p>Now I can't target the right div...</p>
jquery
[5]
953,520
953,521
How Get Message from TCP/IP Python?
<p>how do I get the message that more than two messages in the buffer in the TCP / IP connection in python if I use the XML-RPC. I've tried using Cherrypy if the message is received by a normal state if more than one it will not get the message.</p>
python
[7]
4,396,721
4,396,722
What are the differences between using array offsets vs pointer incrementation?
<p>Given 2 functions, which should be faster, if there is any difference at all? Assume that the input data is very large</p> <pre><code>void iterate1(const char* pIn, int Size) { for ( int offset = 0; offset &lt; Size; ++offset ) { doSomething( pIn[offset] ); } } </code></pre> <p>vs </p> <pre><code>void iterate2(const char* pIn, int Size) { const char* pEnd = pIn+Size; while(pIn != pEnd) { doSomething( *pIn++ ); } } </code></pre> <p>Are there other issues to be considered with either approach?</p>
c++
[6]
1,841,042
1,841,043
How can I fire a jQuery event when scrolling?
<p>I'm so close to having my menu figured out. I've followed the instructions given by jQuery for Designers on <a href="http://jqueryfordesigners.com/fixed-floating-elements/" rel="nofollow">Fixed Floating Elements</a>. I want to extend this by putting the Site Title above the menu I've created when you scroll. </p> <p>I've got it mostly working, but when I scroll, it continues to enter the Site Title text as I scroll. I just want it to enter the site title once—basically making it look like <a href="http://cl.ly/192v1J461j1r3D0x1q27" rel="nofollow">this screenshot</a>. How can I run this <code>.before()</code> only one time?</p> <p>Here's the fiddle I've got so far. <a href="http://jsfiddle.net/saltcod/NwFc9/" rel="nofollow">http://jsfiddle.net/saltcod/NwFc9/</a></p>
jquery
[5]
626,324
626,325
How to display a particular word in bold using jquery?
<p>How to display a particular word in bold using jquery.</p> <pre><code>function OnSuccess(response) { var user = $('#username').val(); if (response.d == 1) { $('#result').text(user + ' already Exists'); $('#Button1').attr('disabled', true); } else { $('#result').text('Username '+user +' Ok'); $('#Button1').attr('disabled', false); } } </code></pre> <p>Here i want to make the username(user) to be bold ,rest of the sentence must be normal.Is it possible by using jquery?</p>
jquery
[5]
5,309,586
5,309,587
jquery toggle on multiple divs only working on first element
<p>ive created a page but it's only toggling the first div and the other 2 arent working... can't work out why! Thanks in advance</p> <pre><code>var levelopen=false; $(document).ready(function() { $('.contentlevel').hide(); $('#levelopener').click(function(){ if(levelopen==false) { $('#levelopener').html('[less]'); levelopen=true; } else { $('#levelopener').html('[more]'); levelopen=false; } $(this).next(".contentlevel").slideToggle(100); return false; }); }); </code></pre> <p><a href="http://jsfiddle.net/q2qxX/4/" rel="nofollow">http://jsfiddle.net/q2qxX/4/</a></p>
jquery
[5]
5,643,180
5,643,181
JQuery text() is not working in Internet Explorer 7
<p>I developed a simple webapp using asp.net, C# and jquery and I'm testing my app using Internet Explorer 7. I used ajax to retrieve data from the server. But calling the text() of jquery is not working, instead it will call the val() method, for example I created a drop down list called NameDrp, then,</p> <pre><code>$("SELECT#NameDrp option:selected").text() </code></pre> <p>The above call will give the value not the text.</p> <p>EDIT: markup of the select</p> <pre><code>&lt;select id="NameDrp" name="NameDrp"&gt; &lt;option value="1"&gt;Monkey&lt;/option&gt; &lt;option value="2"&gt;Lion&lt;/option&gt; &lt;option value="3"&gt;Tiger&lt;/option&gt; &lt;/select&gt; </code></pre>
jquery
[5]
3,770,056
3,770,057
How do I deal with a forced close message on Android?
<p>I am having trouble debugging my app that causes a pop-up "Forced close" message every time I try to use my android app. How can I go around it ?</p>
android
[4]
2,662,726
2,662,727
arrays using python
<p>I have 2 arrays. query_array and stem_array. stem_array has elements in format (word | synonyms). the query_array has words in it.</p> <p>I want to check if the query_array has words that are contained in the synonyms part of the stem_array and if yes, then map the synonym to the actual word.</p> <p>for eg: query_array (presidential, authenticity) stem_array (president | presidential , authentic | authenticity, authentication) so my final array should return (president and authentic).</p> <p>please help me as i am new to python and i have a project to complete.</p> <p>thanks.</p>
python
[7]
1,759,180
1,759,181
Has get_object_vars changed in version 5.4?
<p>I used to get all public vars from a class inside a class with a Closure like this:</p> <pre><code>Class myClass { public $foo; private $bar; private function GetFields() { $lambda = function( $obj ) { return get_object_vars( $obj ); }; return $lambda( $this ); } public function SomeFunction() { $fields = $this-&gt;GetFields(); } } </code></pre> <p>This worked perfect, and gave me all public vars while inside a class.</p> <p>Now, I upgraded my server to PHP 5.4 and I get all privates and protected vars to. Is that a new 'Feature' or is it a Bug?</p>
php
[2]
2,341,249
2,341,250
Replace values in a URI query string
<p>I have part of a query string that I want to make a replacement in. I want to use <code>preg_replace</code> but am kind of hung up on the regex. </p> <p>Can someone please help? What I need replaced are the GET vars.</p> <p>Here is the string:</p> <pre><code>bikeType=G&amp;nikeNumber=4351 </code></pre>
php
[2]
4,129,857
4,129,858
Using interpreter to lookup module 'sys' in Python
<p>So I just installed the python interpreter and wanted to use the help(sys) feature to get more information about the sys module, but I got this error and had no idea what went wrong.</p> <pre><code>C:\Users\Jake&gt;python Python 2.7.2 (default, Jun 12 2011, 14:24:46) [MSC v.1500 64 bit (AMD64)] on win 32 Type "help", "copyright", "credits" or "license" for more information. &gt;&gt;&gt; import sys &gt;&gt;&gt; help(sys) 'more' is not recognized as an internal or external command, operable program or batch file. &gt;&gt;&gt; </code></pre> <p>Is this a matter of not having the source code for the sys module on my computer or something else entirely? Any help would be greatly appreciated.</p>
python
[7]
774,119
774,120
Display number int in Python
<p>How to display numbers integer in python ? For example:</p> <pre><code>number1 = raw_input('Write one number: ') number2 = raw_input('Write other number: ') result = number1 + number2 print "The sum of the numbers is: %d" % result # here, display the result of the operatio n. </code></pre>
python
[7]
4,385,165
4,385,166
Java iterating through all the files and only the unique RAR archives in a directory
<p>How can I iterate over over all the RAR archives in a directory. I know how to iterate over the files in a directory but I'm only interested in RAR archives. If they were simple RAR archives with the extension <code>.rar</code> it wouldn't be an issue but my directories can have multiple spanned archives and I only want the first/main volume in the set. I also would like to have the other files in the directory:</p> <p>Here are the contents of a sample directory:</p> <ul> <li><code>file.txt</code></li> <li><code>somefile.zip</code></li> <li><code>hello.rar</code></li> <li><code>test.part1.rar</code></li> <li><code>test.part2.rar</code></li> <li><code>example.rar</code></li> <li><code>example.r00</code></li> </ul> <p>Result:</p> <ul> <li><code>file.txt</code></li> <li><code>somefile.zip</code></li> <li><code>hello.rar</code></li> <li><code>test.part1.rar</code></li> <li><code>example.rar</code></li> </ul> <p>This is what I'm using ti iterate over the directory:</p> <pre><code> import java.io.File; ... for (File child : (new File(myDirectoryPath)).listFiles()) { if (!child.isDirectory()) { //Do something with the file } } </code></pre> <p>How can I do this? I need to detect whether it is a RAR archive or not. If it isn't, use it. If it is, I'd need to check whether it is the first part of an archive. if yes, do whatever, else ignore it.</p> <p>Thanks</p>
java
[1]
4,377,847
4,377,848
Encrypt a query string inside of an anchor tag
<pre><code>echo '&lt;a class="bigbtn" href="'.'videoview.php?song_id='.$video['song_id'].'&amp;'.'title='.$video['VideoTITLE'].'&amp;'.'group='.$video['GroupName'].'&amp;'.'artist='.$video['ByArtist'].'"&gt;&lt;/a&gt;' ; </code></pre> <p>what is the best way to encrypt the link when appear in the browser a that user cannot tamper with them?. it's not mission critical link. but want to make it a little more secure.</p> <p>i was trying with the urlencode and decode with base64 , but i try to assign the value to a variable like that.</p> <pre><code> $song_id = urldecode(base64_decode($_Get['song_id'])); </code></pre> <p>but the conversion didnot happen.</p> <p>,the decode didnot happen the way that i was thinking.</p>
php
[2]
3,426,196
3,426,197
How to check ensure a array does not contain the same element twice
<p>I have a loop which assigns randomly generated integers into an array. I need a way to ensure the same integer is not input into the array twice.</p> <p>I figured creating a loop inside the overall loop would work but I am unsure on what to execute here.</p> <pre><code>int wwe[] = new int[9]; for(int i = 0; i &lt; 9 ; i++){ int randomIndex = generator.nextInt(wwe.length); wwe[i] = randomIndex; System.out.println(wwe[i]); System.out.println("########"); for(int j = 0; j &lt; 9; j++){ System.out.println("This is the inner element " + wwe[j]); } } </code></pre>
java
[1]
3,970,497
3,970,498
How to disable GestureListener in android?
<p>I have implemented GestureListener, and it is working perfectly, but how can I remove GestureListener from my view?</p> <pre><code>@Override public boolean onTouchEvent(MotionEvent event) { if ( event.getAction() == MotionEvent.ACTION_UP ) { // remove gestureDetector } else { mGestureDetector.onTouchEvent(event); } return true; } </code></pre> <p>Regards, Nishant Shah</p>
android
[4]
1,266,454
1,266,455
Should I cache the return value of a getter if it is just a simple delegate?
<p>For example:</p> <p>I'm creating a CSV file and I have a <code>CsvOptions</code> object which holds several parameters for the CSV file creation.</p> <pre><code>if (cells.hasNext()) { output.write(csvOptions.getDelimiter()); } </code></pre> <p>The <code>csvOptions</code> is just a simple container object, that kind you are tempted to not use any getters at all. The getter just returns the value from a private field.</p> <p>Is it worth to cache the return value of a trivial getter, like <code>getDelimiter()</code> in my example, in terms of</p> <ul> <li>... execution speed?</li> <li>... coding style?</li> </ul>
java
[1]
4,943,333
4,943,334
Initializing Dynamic Array of Strings (C++)
<p>I am working on assignment to create a container class for a dynamic array of strings. I know that it would be much easier/better done with std::vector, but that is not the point. I am having a problem finding the right way to initialize my array in the constructor. The way it is below, I am still being warned by the compiler that the variable lineArray is not used. The program compiles with a warning that lineArray is unused then hangs at runtime.</p> <pre><code>MyBag::MyBag() { nLines = 0; std::string lineArray = new std::string[0] (); } void MyBag::ResizeArray(int newLength) { std::string *newArray = new std::string[newLength]; //create new array with new length for (int nIndex=0; nIndex &lt; nLines; nIndex++) { newArray[nIndex] = lineArray[nIndex]; //copy the old array into the new array } delete[] lineArray; //delete the old array lineArray = newArray; //point the old array to the new array nLines = newLength; //set new array size } void MyBag::add(std::string line) { ResizeArray(nLines+1); //add one to the array size lineArray[nLines] = line; //add the new line to the now extended array nLines++; } </code></pre> <p><a href="http://ideone.com/pxX18m" rel="nofollow">http://ideone.com/pxX18m</a></p>
c++
[6]
195,009
195,010
Application does not run on Nexus 7 but runs on other devices
<p>I have made an application that runs on android phones and emulators pretty well, but it gives me an error when I run it on Nexus 7 :</p> <p>Here is my logcat report :</p> <pre><code>java.lang.RuntimeException: Unable to start activity ComponentInfo{com.aks.mobilereagents/com.aks.mobilereagents.MobileReagentsAc tivity}: java.lang.NullPointerException at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667) at android.app.ActivityThread.access$1500(ActivityThread.java:117) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:130) at android.app.ActivityThread.main(ActivityThread.java:3687) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:8 67) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.NullPointerException at com.aks.mobilereagents.MobileReagentsActivity.onCreate(MobileReagentsActivit y.java:153) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615) ... 11 more </code></pre>
android
[4]
1,357,508
1,357,509
c# find image in html and download them
<p>i want download all images stored in html(web page) , i dont know how much image will be download , and i don`t want use "HTML AGILITY PACK" </p> <p>i search in google but all site make me more confused ,</p> <p>i tried regex but only one result ... , </p>
c#
[0]
5,305,039
5,305,040
how to upgrade php version
<p>I am using crimson editor which is simply a text editor which uses php version 5.2.13 (I know its old). But I want to update the php version to atleast 5.3 because I want to use the fileinfo command which only works on version 5.3 and beyond.</p> <p>So my question is how can I upgrade the phpversion easily and safely?</p>
php
[2]
4,107,699
4,107,700
can we access properties from constructor
<p>I am working on a CSharp code where in constructor i need to access properties of that class. Logically it looks troublesome to me since i will be accessing properties of the object that hasn't is still under construction.</p> <p>Its an old code using c# version 4.0 and i am kind of refactoring it so that's why can't redesign everything from scratch.</p> <p>Thanks</p> <pre><code>class employee { employee() { int square = count * count; } private int count {get;set;} } </code></pre>
c#
[0]
349,314
349,315
Disable page refresh
<p>I need to prevent users from refreshing a page.</p> <ol> <li>I have scripted in such a way that there is no 'forward' or 'backward' movement required.</li> <li>However, if one refreshes the page, 'everything' starts from the beginning. <ul> <li>To save everything before page refresh and restore them after is not ideal.</li> </ul></li> <li>In order to prevent page refresh, I could use an <code>alert();</code>, but there are chances that the user might neglect the warning.</li> <li>Any other choices...???</li> </ol>
javascript
[3]
3,926,086
3,926,087
Android: How do I register applications that are not running, with a service?
<p>Background: Android provides a nice method of backing up data. To have the data of an application backed up whenever a system-wide backup is performed, an application should have a backup agent specified as an attribute of it's application tag, in the applications manifest.</p> <pre><code>&lt;application android:label="MyApplication" android:backupAgent="MyBackupAgent"&gt; </code></pre> <p>Question: I would like to use a similar mechanism for a file retrieval service I am creating. My question is, how does one programatically scan for applications with a given attribute in their application tag, and launch the object associated with that attribute? Is this possible?</p> <p>Note that the target application may not necessarily be running.</p>
android
[4]
3,395,184
3,395,185
How to show div based value from dropdown on click?
<p>I'm trying to show some different divs based on the value a user has choosen, when he/she clicks the "go-button". Here is my script:</p> <pre><code>$(document).ready(function(){ $('#divarea1').hide(); $('#divarea2').hide(); $('#divarea3').hide(); $('#go-button').click(function() { var whatToShow = $('#dropdown').val(); if (whatToShow = ref1) { $('#divarea1').show(); } else if (whatToShow = ref2) { $('#divarea2').show(); } else { $('#divarea3').show(); } }); }); </code></pre> <p>And here is my html:</p> <pre><code>&lt;form name="ref-selector" method="POST" ACTION="URL"&gt; &lt;select id="dropdown" name="dropdown"&gt; &lt;option value="ref1"&gt;Book&lt;/option&gt; &lt;option value="ref2"&gt;Journal&lt;/option&gt; &lt;option value="ref3"&gt;Webpage&lt;/option&gt; &lt;/select&gt; &lt;input type="button" id="go-button" value="Go"&gt; &lt;/form&gt; &lt;div id="divarea1"&gt; &lt;p&gt;Some random content&lt;/p&gt; &lt;/div&gt; &lt;div id="divarea2"&gt; &lt;p&gt;Some other random content&lt;/p&gt; &lt;/div&gt; &lt;div id="divarea3"&gt; &lt;p&gt;The last random content&lt;/p&gt; &lt;/div&gt; </code></pre> <p>I hope some of you will be able to help me. I've tried to look around for solutions, but nothing seems to be what I'm looking for, and I can't get it to work from what else I have read.</p>
jquery
[5]
4,683,012
4,683,013
Running a piece of code when Notification deleted
<p>I'm trying to figure out how to run a piece of code when a notification gets cleared. I've found that the Notification class provides a deleteIntent which is run when the notification is cleared, but I have been unable to find any resource that explains how I could go about getting this to run a piece of code within my application.</p> <p>I was wondering if anyone had any suggestions of how I could achieve this, or could point me towards a good tutorial that will explain how I could go about achieving this. </p>
android
[4]
3,234,047
3,234,048
Run simple php file or call a single php fuction(same as simple php file) which is better?
<p>I have 2 php files (both's output are same) I'st file code</p> <pre><code>&lt;?php function sampleCode() { //code here } //end function sampleCode(); ?&gt; </code></pre> <p>II'nd file code</p> <pre><code>&lt;?php //code here ?&gt; </code></pre> <p>which is better and less use cpu when i don't need to recall or include ?</p>
php
[2]
1,615,717
1,615,718
Problems with Relative layout
<p>I am trying to place two components. The first one (Edittext) should expand till the next component (a submit Button). How do I do this? My XML is as follows... The problem is that the Edittext expands to fill the screen and hides the button:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; </code></pre> <p></p> <pre><code>&lt;EditText android:id="@+id/etFeedBackText" android:hint="What do you think of this app? Any comments or suggestions?" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_alignBottom="@id/btnFeedBackSubmit" &gt; &lt;/EditText&gt; &lt;Button android:id="@+id/btnFeedBackSubmit" android:text="Submit" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_below="@id/etFeedBackText" android:layout_alignParentBottom="true" &gt; </code></pre> <p></p> <p></p>
android
[4]
1,508,432
1,508,433
Javascript trouble parseFloat and if/ else loop
<p>So working on some code and I'm not spotting the issue with my loop in the second function it keeps returning 40, I think the loop is written correctly. I'm guessing its the value passed within the if and else condition? if (par_hour &lt; 40) which comes from parseFloat</p> <pre><code> function addEmployee() { var employees = new Array(); employees[0] = window.prompt("Enter employee name","Bob"); var hours = new Array(); hours[0] = window.prompt("Enter How many hours you have slaved away! ","4.5"); var wages = new Array(); wages[0] = window.prompt("Enter your hourly wages.","10.00"); alert("test"); calculateSalary(hours,wages); alert("How about now"); document.write(regHours); } function calculateSalary(hours,wages) { par_hour = parseFloat(hours[0]); par_wage = parseFloat(wages[0]); if (par_hour &lt; 40) { regHours = par_hour; } else (par_hour &gt;= 40) { regHours = 40; } alert("why wont you work"); } &lt;html&gt; &lt;head&gt; &lt;title&gt;Matt Beckley Week 2 Assignment&lt;/title&gt; &lt;script type ="text/javascript" src="script1.js"&gt; &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;h1&gt;Weekly Gross Salary&lt;/h1&gt; &lt;table border="1"&gt; &lt;tr&gt; &lt;th&gt;Employees&lt;/th&gt; &lt;th&gt;Total Hours&lt;/th&gt; &lt;th&gt;Reg Hours&lt;/th&gt; &lt;th&gt;Reg Pay&lt;/th&gt; &lt;th&gt;OT Hours&lt;/th&gt; &lt;th&gt;OT Pay&lt;/th&gt; &lt;th&gt;Weekly Salary&lt;/th&gt; &lt;/tr&gt; &lt;/table&gt; &lt;a href="salary.html" id="reload" onclick="addEmployee();"&gt;Add Employees&lt;/a&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
javascript
[3]
1,128,496
1,128,497
How to Refresh GridView?
<p>How to Refresh Grid view?</p> <p>I was download image from RSS Site using Image Loader Class but the main Problem is the images was displayed in grid view after i was scrolling the grid view many times otherwise default image is displayed.</p> <p>Please Help me.</p>
android
[4]
5,043,836
5,043,837
Jquery passing function values to a ajax function
<p>I've two jQuery UI date pickers and a drop down box.</p> <p>Each of them are a function. Now how do i take the three function variable and pass it to AJAX function?</p> <p>I tried defining var a global but this is not working.</p> <p><strong>Below is dummy example code</strong></p> <pre><code>$('selector').submit(function() { var a = this.value; }); $('selector').submit(function() { var a = this.value; }); $('selector').submit(function() { var a = this.value; }); $ajax(); </code></pre> <p>Want to pass those variables to ajax function.</p>
jquery
[5]
2,298,360
2,298,361
How to Stop a Service in Android when the application is not running.
<p>I have Started my service in one of my main activity class.The problem is that when my application is not running I want to Stop my service.How can i implement this.Is there any option to stop it without stopping it using any button click or other click events of the control.</p> <p>Also is there any way to indicate the service is running or not while my application is running</p>
android
[4]
534,812
534,813
Android Mobile number and Wi-Fi MAC address
<p>I want to know Mobile number and Wi-Fi-Address .Howis this possible.Can anyone Help me</p>
android
[4]
883,793
883,794
Need to flash the screen GREEN for 5 secs
<p>I have a particular requirement.</p> <pre><code>if(condition true){ Flash the screen GREEN for 5 secs }else{ Flash the screen RED for 5 secs } </code></pre> <p>Could anyone please help in this regard?</p>
android
[4]
4,009,446
4,009,447
inserting characters at the start and end of a string
<p>I am new and trying to find a way to insert a number of L's at the beginning and end of a string. So if I have a string which says </p> <p>"where did I put my cupcake this morning" </p> <p>And I want to insert 1 L at the start and 2 L's at the end, so it looks like: "Lwhere did I put my cupcake this morningLL" How do I do this. thank you</p>
python
[7]
3,237,751
3,237,752
Shutdown BlueCove stack programmatically
<p>Is there any way to shutdown the BlueCove stack, in my application user can able to start, stop and restart the bluetooth server whenever they wish, for that I can able to start the server, listen for connection, accept message from the client. But when I try to stop and restart the BlueCove, I'm gettting BluetoothStateException, instead I've to restart the application itself.</p> <p>For shutting down I used,</p> <pre><code>BlueCoveImpl.shutdown(); </code></pre> <p>and another thing</p> <pre><code>BlueCoveImpl blueCoveImpl = BlueCoveImpl.instance(); blueCoveImpl.setBluetoothStack(null); </code></pre> <p>but both not worked for me.</p> <p>Any Ideas to do this.</p> <p>EDIT: When I close the whole application it displays </p> <blockquote> <p>BlueCove stack shutdown completed</p> </blockquote> <p>in the Console.</p> <p>Thanks.</p>
java
[1]
2,651,684
2,651,685
How to randomly place 2 unique points on a 2D array?
<p>The picking itself is easy, but I'm having trouble making sure I can't place the points on the same spot. I could of course re-random, but is there a better way? Thanks a lot!</p>
c++
[6]
4,315,689
4,315,690
Android: there is an error when i click on my editText
<p>I am working in android. i have a problem. my application crashes when i click on my text box second time.</p> <p>this is my Logcat message:</p> <pre><code>java.lang.IndexOutOfBoundsException: setSpan (4 ... 4) ends beyond length 0 android.text.SpannableStringBuilder.checkRange(SpannableStringBuilder.java:943) android.text.SpannableStringBuilder.setSpan(SpannableStringBuilder.java:522) android.text.SpannableStringBuilder.setSpan(SpannableStringBuilder.java:514) android.text.Selection.setSelection(Selection.java:74) android.text.Selection.setSelection(Selection.java:85) android.text.method.ArrowKeyMovementMethod.onTouchEvent(ArrowKeyMovementMethod.java:410) android.widget.TextView.onTouchEvent(TextView.java:6715) android.widget.EditText.onTouchEvent(EditText.java:190) android.view.View.dispatchTouchEvent(View.java:3766) android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936) android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936) android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936) android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936) android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936) android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936) android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936) com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1731) com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1120) android.app.Activity.dispatchTouchEvent(Activity.java:2086) com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1715) android.view.ViewRoot.handleMessage(ViewRoot.java:1787) android.os.Handler.dispatchMessage(Handler.java:99) </code></pre> <p>please help me to find out the cause of this problem. Thank you in advance.</p>
android
[4]
4,427,722
4,427,723
how to show tab bar like iphone
<p>how to show tab bar below of the screen like in iphone in android?</p>
android
[4]
5,381,965
5,381,966
What is the difference if I put Main() inside a struct instead of a class?
<p>What is the difference if I put the static method <code>Main()</code> inside a struct instead of a class?</p> <pre><code>struct Program { static void Main(string[] args) { System.Console.WriteLine("Hello World"); } } </code></pre> <p>If there is no difference, why did Microsoft choose a class for its container by default?</p>
c#
[0]
1,614,309
1,614,310
js creating abstract class
<p>i am trying to create a abstract class (mimicking oops) in js using below declaration. If i use prototype keyword for every method below it fails (see case-1 below) however when i use without prototype keyword it works not sure am i declaring it correclty.. however same declaration works when js file is declared to the main page but fails when invoke from dialog box.. i think declaration is issue</p> <pre><code>if(nsp === undefined) var nsp = {}; // nsp is the namespace nsp.abstractCls= function(){} ; //abstractCls is the abstract function &amp; subclass function will extend perfAction methods (overriden methods) nsp.abstractCls.prototype ={}; //case-1 fails , throws error is not a function (prototype keyword is present) nsp.abstractCls.prototype.perfActiOn = function(){ return "success"; } ; //case-2 this works (no prototype keyword) nsp.abstractCls.perfActiOn = function(){ return "success"; } ; </code></pre> <p>Statment nsp.abstractTbl.prototype.perfTable wroks but not sure is it correct approach to have prototype keyword to invoke every function..</p>
javascript
[3]
552,691
552,692
In Js How to wrap all last childred of an oject tree?
<p>Just wanted to write some recursion but can't check if the child is in fact some finite thing, when checking throught jQuery.isPlainObject , just getting a saparate letters as a childs , like I want "this is error message" - to be a last child , but can't detect it</p>
javascript
[3]
4,452,470
4,452,471
Developing a polling mechanism
<p>In C#, what is the best way to create a polling mechanism? So I have some code which can periodically do some action.</p> <p>This is for web services so any UI-related solutions won't apply.</p> <p>Thanks</p>
c#
[0]
310,606
310,607
howto change method indexer to propoties of indexer?
<pre><code>public ArrayList choiceArray = new ArrayList(); public UC_RadioX Item(int index) { return (UC_RadioX)choiceArray[index]; } </code></pre> <p>when i used</p> <pre><code> cc.Item(0).Checked = true; cc.Item(1).Checked = true; </code></pre> <p>howto change method to propoties</p>
c#
[0]
4,048,975
4,048,976
deep copy cloning via serialization
<p>I came accross this:</p> <p><a href="http://www.codeproject.com/KB/tips/SerializedObjectCloner.aspx" rel="nofollow">http://www.codeproject.com/KB/tips/SerializedObjectCloner.aspx</a></p> <p>and would like to use it to deep copy a object graph. Is it sufficient to mark all the classes that potentially participate in the object graph with:</p> <pre><code>[Serializable()] </code></pre> <p>and then invoke the clone method as suggested in the article?</p> <p>I have my doubts that it is that simple and I may have to implement more?! Thought I ask the experts first before I dig any deeper.</p> <p>Thanks.</p> <p>Christian</p>
c#
[0]
5,838,873
5,838,874
Which approach is "better" (in terms of optimization and complexity)
<p>Suppose that whe have some object, derived from these class instances</p> <pre><code>class A { ... private b //list of object of class B } class B { ... private c //list of object of class C } class C { ... private id } </code></pre> <p>Now, somewhere in my code, I've got this situation</p> <pre><code>function findId(array $idList) { [...] } </code></pre> <p>Where I have to find (for each element of <code>$idList</code>) if an element is contained into this object "cascade"</p> <h1>First solution</h1> <pre><code>//object initialization foreach($a-&gt;getB() as $b) { foreach($b-&gt;getC() as $c) { foreach($idList as $id) { if($id == $c-&gt;getId()) { //do something an break the cycle } } } } </code></pre> <h1>Second Solution</h1> <pre><code>//object initialization $idSet = array(); foreach($a-&gt;getB() as $b) { foreach($b-&gt;getC() as $c) { $idSet[] = $c-&gt;getId(); } } $idSet = array_unique($idSet); foreach($idList as $id) { if(array_search($id,$idSet) !== false) { [...] } } </code></pre> <p>Which is better? There are some alternative methods for reach my goal?</p> <h1>IMPORTANT</h1> <p>There isn't better data representation. This because these objects are some database object (doctrine2)</p>
php
[2]
2,111,941
2,111,942
PHP Security on Forms and DOM Manipulation
<p>I was having an interesting discussion with a fellow co-worker about security in PHP.</p> <p>Let's say a person has a PHP site running with a standard HTML form. An attacked decides to use Chrome Developer tools and add in the DOM <code>enctype="multipart/form-data"</code> and a <code>file input</code>. </p> <p>The attacker uploads a file, it probably won't execute if it were a virus yet it's still using bandwidth/storage for that moment. Would the file go into the PHP <code>/tmp</code> directory just by doing this? Wouldn't this make every form some-what insecure as a user can upload a file in any form?</p> <p>On a bigger scale what if 100,000 people added that to the DOM and uploaded a random gigabyte file? Wouldn't that temporarily make them hit their bandwidth and/or storage mark?</p>
php
[2]
778,584
778,585
How do I control the alignment of formatted text in Java?
<p>I'm knocking my head here using System.out.printf and I really don't understand something that seems that it should be much more simple.</p> <pre><code>public class main{ public static void main(String args[]){ double dog = 3.85; double cat = 333.85; System.out.printf("Hola:%7.1f\n",dog); System.out.printf("Hola:%5.0f", cat); } } </code></pre> <p>I'm trying to understand what the significance is of the numbers after the percentage symbol. In short in the line:</p> <pre><code>System.out.print("Number: %x.y", someNumber); </code></pre> <p>what does the x tell me and what does the y tell me?</p>
java
[1]
3,154,354
3,154,355
destructor of a singleton class is called twice!
<p>i have the code as below :</p> <pre><code> class Singleton { private: int i; static bool stnflag; static Singleton* single; Singleton(int a) { i=a; } public: static Singleton* getinstance(int); void function(); ~Singleton() { cout &lt;&lt; "destructor is being called" &lt;&lt; endl; stnflag=false; } }; bool Singleton::stnflag=false; Singleton* Singleton::single=NULL; Singleton* Singleton::getinstance(int a) { if(!stnflag) { single = new Singleton(a); stnflag=true; return single; } else { cout &lt;&lt; "already single object created" &lt;&lt; endl; return single; } } void Singleton::function() { cout &lt;&lt; "private member value in single ton class is :" &lt;&lt; i &lt;&lt; endl; } int main() { Singleton *s1,*s2; s1=Singleton::getinstance(3); s1-&gt;function(); s2=Singleton::getinstance(4); s2-&gt;function(); delete s1; delete s2; return 0; } </code></pre> <p>when delete s2 is called the destructor is called second time also!!but how it is possible? already the pointer of the object is deleted at delete s1 ri8..but i'm getting the print statement in the destructor for second delete s2 too..can anybody giveme the reason..but as per my assumption it shud through an error of double free pointer ri8!!</p>
c++
[6]
4,202,468
4,202,469
Call class method while instantiating?
<p>I don't know how to describe it better so the title might be a bit confusing.</p> <p>I would like to know if it is possible to instantiate a class by using <code>... = new MyClass()</code> and to call non static methods of this class instantly while instantiating?</p> <p>For example something like that:</p> <pre><code>return new MyClass().SetName("some name"); </code></pre> <p>I guess I have seen something similar like this before but I can't find it. It is a bit annoying to do something like...</p> <pre><code>MyClass myclass = new MyClass(); myclass.SetName("some name"); return myclass; </code></pre> <p>Is there a way to shorten it or to do it like my first example? (Please do not suggest me to use a property instead of <code>SetName(string)</code> - it is just an example)</p> <p>Thanks in advance!</p>
c#
[0]
786,868
786,869
How to display Current Location ADDRESS in textbox?
<p>I've created this Textbox, and a Button beside it. I've also linked this Button to a class which display a map with the longitude, latitude, a push pin etc. But i have a question, how do i make this textbox such that it auto generate the current location address ? </p>
android
[4]
1,106,359
1,106,360
How to get the html header values like h1 using html parser dom?
<p>how to get the header value like h1 or h2 which lies inside a div having some class name using simple html parser dom? ex: - <code>&lt;html&gt; &lt;body&gt; &lt;div class="somename"&gt; &lt;h1&gt;MyText&lt;/h1&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt;</code></p>
php
[2]
5,340,471
5,340,472
ImageButton doesn't scale / adapt according to different resolutions
<p>I have a imagebutton placed inside a RelativeLayout. However I can't seem to figure out what I need to do in order for the button to scale according to different resolutions.</p> <p>Here's the content of my activity_main.xml:</p> <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/RelativeLayout1" android:layout_width="fill_parent" android:layout_height="fill_parent"&gt; &lt;ImageView android:id="@+id/imageView1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:src="@drawable/background" android:scaleType="fitCenter" android:gravity="center"/&gt; &lt;ImageButton android:id="@+id/imageButton1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:background="@null" android:onClick="startVideo" android:scaleType="fitCenter" android:src="@drawable/button" android:layout_marginBottom="50dp"/&gt; &lt;/RelativeLayout&gt; </code></pre> <p>background.png is an image placed in the mdpi folder (1280x800px), button.png is also placed in the mdpi folder (757x271px). </p> <p>If I run my app on a 1280x800px resolution (galaxy tab) it looks fine, however when I try to run the app on my phone the ImageButton doesn't scale down - it keeps the original size (757x271px).</p> <p>Does anyone know a solution for this?</p>
android
[4]
4,903,476
4,903,477
Reading a javascript script, why so many $ (dollar signs)?
<p>I am trying to decipher a .js script and I am finding it filled with $ throughout? Is there any reason to use this? I'm pretty new to JavaScript.</p>
javascript
[3]
5,558,791
5,558,792
Isinstance() doesn't work
<p>For some reason I can't get isinstance() to work on Python 2.7.2</p> <pre><code>def print_lol(the_list, indent=False, level=0): for item in the_list: if isinstance(item, list): print_lol(item, indent, level+1) else: print(item) </code></pre> <p>And when I compile and run it:</p> <pre><code>&gt;&gt;&gt; list = ["q", "w", ["D", ["E", "I"]]] &gt;&gt;&gt; print_lol(list) </code></pre> <p>I get the error message:</p> <pre><code>if isinstance(item, list): TypeError: isinstance() arg 2 must be a class, type, or tuple of classes and types </code></pre> <p>What am I mising?</p>
python
[7]
1,851,427
1,851,428
How to execute the loop for specific time
<p>How can i execute the a particluar loop for specified time</p> <pre><code>Timeinsecond = 600 int time = 0; while (Timeinsecond &gt; time) { // do something here } </code></pre> <p>How can i set the time varaible here, if i can use the Timer object start and stop method it doesnot return me time in seconds</p> <p>Regards NewDev</p>
c#
[0]
5,256,425
5,256,426
A simple script that works for hover, but why can't I get it to work for clicks?
<p>I have a very simple js script that works for hovers, but I want to convert the hover into a click feature. When I try to switch hover to click though, it does not work.</p> <p>Here is the complete example script just for reference. When someone hovers over this class, a little text with a background appears below. <a href="http://pastebin.com/JMTfvDAa" rel="nofollow">http://pastebin.com/JMTfvDAa</a></p> <p>Here's what I tried for click <a href="http://pastebin.com/M0X37APD" rel="nofollow">http://pastebin.com/M0X37APD</a></p> <p>If someone could help me covert the hover into click, I would heavily appreciate it!</p> <p>Thanks,</p>
jquery
[5]
3,882,096
3,882,097
jQuery code difference
<p>Let me start by saying that I'm not a JavaScript programer or a jQuery guru by any means, I'm actually just starting with jQuery.</p> <p>I have the two following jQuery codes:</p> <pre><code>$('.tipTrigger').hover(function(){ $(this).toggleClass('active').prev('.tipText').stop(true, true).fadeToggle('fast'); }); </code></pre> <p>and</p> <pre><code>if ($(".tooltip-container").length &gt; 0){ $('.tipTrigger').hover(function(){ $(this).toggleClass('active').prev('.tipText').stop(true, true).fadeToggle('fast'); }); } </code></pre> <p>Several questions I have about this:</p> <ol> <li>What is basically the difference between the two codes above?</li> <li>What is the meaning of <code>if ($(".tooltip-container").length &gt; 0){</code>?</li> <li>Is there a benefit to using the above <code>if</code>?</li> <li>What's more 'efficient' from a developer's stand point? (that is IF something so small would have a considerable performance impact in any way)</li> </ol> <p>Any other comments/help with this simple comparison would be greatly appreciated.</p> <p>Thanks in advance.</p>
jquery
[5]
654,747
654,748
Android: Fetching an XML from a web service: Threads
<p>Fetching an XML from a web service in background and displaying a progress bar in front while the xml is being downloaded in Android</p>
android
[4]
3,296,935
3,296,936
getelementbyid and tagname and classname
<p>I want to know how you can get element using pure javascript.</p> <p>I have my code below:</p> <pre><code> &lt;html&gt; &lt;body&gt; &lt;div id="abc" class="xy"&gt; 123 &lt;/div&gt; &lt;p id="abc" class="xyz"&gt; 123 &lt;/p&gt; &lt;span id="foo" class="foo2"&gt; foo3 &lt;/span&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Here i want to find element with combination:</p> <ol> <li>find element has id abc and tagname p</li> <li>find element has id abc and classname xy</li> <li>find element has classname foo2 and tagname span</li> <li>find element has id abc and classname xy and tagname div</li> </ol> <p>I know we can't use more than one id per page. But in worse situation is it ok to have same ID to different tags? in html?</p>
javascript
[3]
3,617,344
3,617,345
JSObject: Download it or available in JRE 1.6?
<p>This is a question from a Java noob.</p> <p>I have eclipse open (JRE 1.6), <a href="http://svn.littleshoot.org/svn/littleshoot/trunk/client/applet/src/main/java/LittleShootApplet.java">I have copied this code into an eclipse class</a>.</p> <p>The line in question is this:</p> <pre><code>import netscape.javascript.JSObject; </code></pre> <p>Eclipse is complaining that the import can not be resolved. I read that in the docs that the Java Plug-In comes as standard and contains the above. I assumed I don't need any extra JAR files. Is this true?</p> <p>Or do I need to download something to make use of JSObject?</p> <p>Thanks all</p>
java
[1]
1,869,845
1,869,846
Script doesnt recognize the file even though the file is present
<p>I am trying to open a file "test_msm8974.sh" from the root directory using the following code,even though the file is present I keep getting the error beow,is there a better way to implement this or suggestions on why the script is not finding it?</p> <pre><code>try: with open("test_" + target + ".sh") as f: pass copy("test_" + target + ".sh", BUILD_ROOT_DIR) except IOError as e: print "test_" + target + ".sh" + " file missing" raise </code></pre> <p>I keep getting the following error even though the file is present</p> <pre><code>Traceback (most recent call last): File "g2g_integration.py", line 612, in &lt;module&gt; main() File "g2g_integration.py", line 430, in main with open("test_" + target + ".sh") as f: pass IOError: [Errno 2] No such file or directory: 'test_msm8974.sh' </code></pre>
python
[7]
123,637
123,638
Question related to UITextView
<p>How to adjust height of textview programetically as we are typing the text textview should increase upwards with no limit.UIScrollview for textview is disable in our case.We are giving scroll for entire view to see upward contents in textview</p>
iphone
[8]
3,298,434
3,298,435
Is there a way to take a memory dump on app crash?
<p>I am busy writing an app and I have noticed that it sometimes crashes, and when it does and I get back to my computer then I only have the stack trace.</p> <p>Is there a way for me to take a memory dump of the app at crash time?</p> <p>Thanks</p>
android
[4]
5,984,531
5,984,532
How to Listview updated after delete database?
<pre><code>ListView lv = (ListView) findViewById(R.id.list); lv.refreshDrawableState(); </code></pre> <p>is not working.</p>
android
[4]
3,208,117
3,208,118
Export a webpage using query and php
<p>I have tables and images in a php webpage. I want to export all the data to pdf. Can anybody tel me how do I export the data to pdf using jquery?</p> <p>Thank You</p>
jquery
[5]
1,980,275
1,980,276
Exception while parsing Date
<p>I'm getting a datetime from a webservice, wich is actually pulling the data from a sqlserver db, the problem is I'm getting a parse exception when I try to convert the string to Date:</p> <p>Here is my code: </p> <pre><code>String tschedule = json.getString("ScheduledFor"); String tduration = json.getString("Duration"); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); SimpleDateFormat dateFormat1 = new SimpleDateFormat("HH:mm:ss"); Date schedule = new Date(); Date duration = new Date(); try { schedule = dateFormat.parse(tschedule); //exception here, tschedule="2013-04-12T11:25:26.703" duration = dateFormat1.parse(tduration);//or exception here, tduration="03:10:00" } catch(Exception ex) { Log.e("MEETINGS SERVICE", "Parse exception: " + ex.getMessage()); } </code></pre> <p><strong>UPDATE</strong>: Logcat ouptut: 04-18 18:54:48.690: E/MEETINGS SERVICE(8601): DateParse exception: Unparseable date: 2013-04-12T11:25:26.703</p>
android
[4]
4,602,891
4,602,892
Problems trying to assign **varname to *varname[]. c++
<p>In my .h, I have a variable, <code>Texture ** skyboxTextures</code>. I assign some texture pointers in one method, and use them right away:</p> <pre><code>Texture *skt[] = { tleft, tright, tfront, tback, tup, tdown }; skyboxTextures = skt; for(int i = 0; i &lt; 6; i++) { skyboxTextures[i]-&gt;load(); } </code></pre> <p>Then later in another method I try to use the textures again.</p> <pre><code>Texture *skt[] = skyboxTextures; // Render the front quad skyboxTextures[0]-&gt;activate(); </code></pre> <p>This is my issue I cannot access my objects any more. This will not compile because of this error:</p> <pre><code>error C2440: 'initializing' : cannot convert from 'Texture **' to 'Texture *[]' </code></pre> <p>If I comment out the line <code>Texture *skt[] = skyboxTextures;</code>, all I get are invalid texture pointers.</p>
c++
[6]
111,235
111,236
Why is REL not detected in a jQuery attribute selector
<p>If I use the following selector I get no results</p> <pre><code>$(".itemSearchModule .cmsItemList[rel='myRelValue']") </code></pre> <p>for the following html snippet</p> <pre><code>&lt;div class="itemSearchModule"&gt; &lt;ul class="cmsItemList" rel="myRelValue"&gt; &lt;li&gt;something&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; </code></pre> <p><strong>MISTAKE</strong> I was using firebug to debug the code and it seems that using that code in firebugs watch window is what is causing it to break</p>
jquery
[5]
2,140,025
2,140,026
.load() now loading live data into the div in IE9 works fine in FF and chrome
<p>After adding a new data I am reloading the div with new data. IT works fine in FF and chrome but it load crap data in IE9.</p> <pre><code>$('#tabledata').load('load.php'); </code></pre>
jquery
[5]
4,558,996
4,558,997
Looping through Javascript Method and add data to the Method
<p>I have a Array of Month Values inside JavaScript .</p> <pre><code>var myarray = new Array(); myarray2.push("January"); myarray2.push("February"); myarray2.push("March"); myarray2.push("April"); myarray2.push("May"); myarray2.push("Jun"); myarray2.push("Jul"); myarray2.push("Aug"); myarray2.push("Sept"); myarray2.push("Oct"); </code></pre> <p>How can i loop through this Array and add inside my addAxis Method ??</p> <p>Currently i have added it statically as shown , but how can i add them dynamically ?? </p> <pre><code>chart1.addAxis("x", { fixLower: "none", fixUpper: "none", natural: true, majorTick: { length: 3 }, labels: [ {value: 1, text: "January"}, {value: 2, text: "February"}, {value: 3, text: "March"}, {value: 4, text: "April"}, {value: 5, text: "May"}, {value: 6, text: "Jun"}, {value: 7, text: "Jul"}, {value: 8, text: "Aug"}, {value: 9, text: "Sept"}, {value: 10, text: "Oct"} ] }); </code></pre>
javascript
[3]