Unnamed: 0
int64
65
6.03M
Id
int64
66
6.03M
Title
stringlengths
10
191
input
stringlengths
23
4.18k
output
stringclasses
10 values
Tag_Number
stringclasses
10 values
5,350,147
5,350,148
How could I make this simple code more efficient?
<p>I'm new to programming in general, and since I'm purely self taught, I lack some of the fundamentals of programming. This is some simple jQuery I wrote to make sure that the wrapper of a site stretches to the beginning of the footer, even if there isn't enough content:</p> <pre><code>$(window).resize(function() { var footerHeight = 147; var windowHeight = $(window).height(); var properHeight = windowHeight - footerHeight; $('#main').height(properHeight); }); </code></pre> <p>I define the height of the footer. Then I get the height of the viewport. Then I minus the height of the footer from the viewport. Then I apply that height to the <code>#main</code> element. I know I can use jQuery to get the height of the footer, but I had issues and it wasn't working right for some reason.</p> <p>I have the code repeated just before, but outside of the <code>$('window').resize()</code> function, so that it runs once on on page load.</p> <p>I feel like I could turn this into a function since it's repeated twice. Also, my main reason for asking here, is because if I resize the browser quickly for a couple seconds, my browser just eats up the CPU because of this code.</p> <p>Apologies if this isn't the right site to ask.</p>
jquery
[5]
5,037,014
5,037,015
Dynamic created JSON String to send via Ajax
<p>I have a form and want to send the data via AJAX in a JSON Format over to my PHP File. I use jQuery to handle all the events.</p> <p>I now got stuck and try to find for hours to find a way.</p> <p>My Data String looks right now like this:</p> <p>search = {name:$('#name').val(),group:$('#group').val()};</p> <p>But I have now decided that I only want fields send over, if there is actually a Value set in it. So I created the follwoing part:</p> <pre><code>$('#search_form input[type=text]').each(function(n,element){ if ($(element).val() != '') { search_fields = {test :$('#'+element.id).val()}; } }); </code></pre> <p>I now want to replace the part where it says test with the input field name and than I would have the value sitting next to it. I hope I explain it right. How would I be able to do this? Because it could be up to 3 Input Fields and I want them to add themself if they have a value or leave them out. Any hint?</p>
jquery
[5]
2,955,930
2,955,931
convert into bind_param type
<p>I'm still new on php bind_param and i'm wandering how to convert this (search) part of the script to avoid sql injection? And i'm still stuck (actually do not know what to do with this: </p> <pre><code> $rest.="where name like '%".$name."%'"; $rest.="where country='".$country."' $rest.="where ip = '".$ip."' </code></pre> <p>//////////////////////////////////////////////////////////////////////////// <pre><code> $name = $_POST['name']; $country = $_POST['country']; $ip = $_POST['ip']; $o="AND"; $rest=""; $text="Search Keywords : "; if($name!="") { if($rest=="") { $rest.="where name like '%".$name."%'"; $text.="Name like ".$name." "; } else { $rest.="$o name like '%".$name."%'"; $text.="Name like ".$name." "; } } if($country!="") { if($rest=="") { $rest.="where country='".$country."' "; $text.="Country = ".$country.""; } else { $rest.=" $o country='".$country."' "; $text.=", Country = ".$country.""; } } if($ip!="") { if($rest=="") { $rest.="where ip = '".$ip."' "; $text.="Ip Address = ".$ip." "; } else { $rest.=" $o ip = '".$ip."' "; $text.=", Ip Address = ".$ip." "; } } if($rest!="") { $rest=$rest; } else { } $stmt = $mysqli-&gt;prepare("select $search.* from $search $rest order by id"); $stmt-&gt;execute(); $stmt-&gt;store_result(); $num = $stmt-&gt;num_rows; </code></pre>
php
[2]
5,740,414
5,740,415
Expected Expression
<p>I cannot figure out what I did or did not do here syntactically to cause this error. I don't see what's missing:</p> <pre><code>function ShowWaitMessage(button) { var isValid; if (buttonSelected()) { showWaitMessage(button, "showMessage1"); isValid = true; } else { Page_ClientValidate(); if (Page_IsValid) { showWaitMessage(button, "showMessage2"); isValid = true; } } return isValid; } </code></pre>
javascript
[3]
1,015,042
1,015,043
How to pass a select to a jquery function
<p>I have some javascript where I append an option to a select:</p> <pre><code>var myuniqueddl = $('#myuniqueddl'); $("&lt;option value='0'&gt;--- Select a value ---&lt;/option&gt;").appendTo(myuniqueddl); </code></pre> <p>I'm actually trying to do this for another select as well.</p> <p>I'm wondering to avoid code duplication should I be passing the ddl to a method to do this?</p> <pre><code>function(someType ddl) { $("&lt;option value='0'&gt;--- Select a value ---&lt;/option&gt;").appendTo(ddl); } </code></pre> <p>Is this a bad idea to be passing a select to a method?</p> <p>Any better way of doing this?</p> <p>If this way is ok what type do I pass it in as?</p>
jquery
[5]
2,849,146
2,849,147
Orientation issues in the webview after zooming in Iphone?
<p>I am loading a pdf file in my resource to a webview which is a subview of a UIView. It's working fine in all orientations. But when I zoom in and out once, then the landscape width is not getting to the pdf. The pdf file is still showing in the size of portrait mode..Can anyone help me ?</p>
iphone
[8]
3,054,859
3,054,860
Android Browser output download time
<p>I'm looking for a way to output the total download time every time a new page is opened in the Android browser.</p> <p>I've looked around, but can't find a place to put a timestamp for downloading a web page. There's a performance monitor in onPageStarted and onPageFinished measuring the page loading time, but nothing (that I can see) that measures the download time.</p>
android
[4]
366,779
366,780
Detecting keyPress inside an IFRAME using jQuery
<p>can i detecting keyPress inside an IFRAME using jQuery? when user paste any copy text in ifram i want to check this text, Is this text contain HTML tags or not.</p> <p>Please help me. </p> <pre><code>&lt;iframe class="abc"&gt; &lt;html&gt; &lt;head&gt; &lt;/head&gt; &lt;body&gt; some text here(This text may contain html tag) &lt;/body&gt; &lt;/html&gt; &lt;/iframe&gt; </code></pre>
jquery
[5]
2,700,356
2,700,357
getting json data from POST
<p>console.log(data) gives the following results</p> <pre><code>{ "ERRORS": [ { "MESSAGE": "Error on API.", "CODE": "hermes05" } ], "DATA": {} } </code></pre> <p>When I try to get the value message out I get undefined, why?</p> <pre><code>error: function(data){ console.log(data.ERRORS[0].MESSAGE); } </code></pre> <p>FULL CODE</p> <pre><code> $.ajax({ type: "POST", dataType: "json", url: "http://api.domain.com/something", data: { // Send value in mobile input field. mobile: $("#mobileNo").val() }, success: function(data){ }, error: function(data){ console.log(data.ERRORS.MESSAGE); } }); // stop button from submitting. event.preventDefault(); // cancel default behavior }); </code></pre>
jquery
[5]
1,656,209
1,656,210
Insert HTML Components inside Javascript File (JS File)
<p>I have this below code inside my javascript file </p> <pre><code>containers: {price: null, volume: null}, buildDOM: function () { var container = $(this.id); this.containers.price = new Element('div', {id: 'priceGraph', style: 'width: 100%; height: 240px;'}); this.containers.volume = new Element('div', {id: 'volumeGraph', style: 'width: 100%; height: 200px;'}); container.insert(this.containers.price); container.insert(this.containers.volume); } </code></pre> <p>I want to have two Text Input (HTML Components) between the two divs (PriceGraph and VolumeGraph) .</p> <p>The whole source code can be found here </p> <p><a href="http://www.humblesoftware.com/finance/source" rel="nofollow">http://www.humblesoftware.com/finance/source</a> (Inside the HumbleFinance.js) </p> <p>Please tell me if its possible to insert the HTML Components in between them )</p>
javascript
[3]
5,310,951
5,310,952
java io read and write lock
<p>suppose I have a file that might gets written by one thread/process Writer and read by another thread/process Reader. Writer updates the file every x time interval, and Reader reads it every y time interval, if they happen to read and write to the file at the same time, will there be any issues? would the read block until writes finishes? or would the read fails? and vice versa? What's the best practice here?</p>
java
[1]
4,843,146
4,843,147
New to JS, want to display strings
<p>Say I have JSON object with data like this (in a separate .json file):</p> <pre><code>evidenceStrings = [ {"jokeid": 0, "evidence": ["\My God you're right! I never would've thought of that!", "this look that says \My God you're right! I never would've thought of that!\", " \My God you're right! I never would've thought of that!\"]}, {"jokeid": 1, "evidence": ["the man didn't have to watch"]}, {"jokeid": 2, "evidence": ["knocking down trees with your face", "knocking down trees with your face. ", " knocking down trees with your face. ", "with your face.", "knocking down trees with your face"]} ] </code></pre> <p>I want to display the "evidence" in an HTML file. The problem is that I'm reading content from another .js file and displaying it's content using a for loop.</p> <pre><code>for(var i = 0; i &lt; jokes.length; i++) { // display string at index 0 of an array in a .js file </code></pre> <p><code>i</code> here refers to the <code>jokeid</code> in the JSON object. Now what I want is, that for the given <code>i</code>, extract my <code>evidence</code> from the JSON object, and display it (preferably with a newline after every string.</p>
javascript
[3]
128,846
128,847
how to check the SharedPreferences string is empty or null *android
<p>i want to check string in SharedPreferences, i used it to store username and password, so if username and password is not null or empty it will be directed to home, otherwise if the username and password is empty it will be directed to login page.</p> <p>this is my <strong>code</strong> to check the SharedPreferences string, but it is not working..</p> <pre><code>if(PreferenceConnector.USERNAME!=null){ Intent intent = new Intent(MainActivity.this,MainHome_Activity.class); startActivity(intent); } else { Intent intent = new Intent(MainActivity.this,LoginFormPegawai_Activity.class); startActivity(intent); } </code></pre> <p>i tried to check it through toast with this code, and after i tried this, its always says that the SharedPreferences string is not null or empty..</p> <pre><code>btn_logout_pegawai.setOnClickListener(new OnClickListener() { public void onClick(View v) { //remove the SharedPreferences string PreferenceConnector.getEditor(this).remove(PreferenceConnector.USERNAME) .commit(); PreferenceConnector.getEditor(this).remove(PreferenceConnector.PASSWORD) .commit(); //checking the SharedPreferences string if(PreferenceConnector.USERNAME!=null) { Toast.makeText(MainHome_Activity.this,"not null", Toast.LENGTH_SHORT).show(); }else { Toast.makeText(MainHome_Activity.this,"null", Toast.LENGTH_SHORT).show(); } } }); </code></pre> <p>how can correctly check the SharedPreferences string whether its empty or null?</p> <p>thanks..</p>
android
[4]
901,951
901,952
Button onclick not firing the event in Android
<p>Here is my button on click listener. I am trying to listen to the onclick event firing. But it is not working. I have tried the method given in develop.android.com. But this method seems to be not working. Can anyone point out the mistake that I am doing here?</p> <pre><code> public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Bundle args = getArguments(); v = inflater.inflate(R.layout.product_fragment, container, false); Button button = (Button) v.findViewById(R.id.buynow_button); button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Toast.makeText(getActivity(), "test", 2000); } }); return v; } </code></pre>
android
[4]
2,608,557
2,608,558
Save Files that containing Files Name with Different Characters using PHP
<p>I am trying to upload files using php. Uploading is working. But i have a file which contain file name (not content) with different language. (ex. japaneese characters). But after i upload that file to server; file name showing with different characters. How do i upload Same file name to the Server.</p>
php
[2]
414,135
414,136
How can I build own Payment Gateway in PHP
<p>I want to build my own payment gateway and provide functionality like paypal.</p> <p>Please help me.</p>
php
[2]
4,210,490
4,210,491
Print all lines in datafile without if condition
<pre><code>file = open("datafile1.txt", "rU") for line in file: line = line.strip() print line for element in line: line = 2 </code></pre> <p>Here is what i have so far, and the output looks like from a simple datafile i created:</p> <pre><code>blind element baker enjoy </code></pre> <p>Which corresponds to what is entered into the datafile1 that i want to read. I am trying to read this datafile1 and print all the lines, but the first one without a if condition. I was thinking of slicing [2:] in the for loop, but i can't figure out how to just print the element,baker, and enjoy "without print the first line which is blind".</p> <p>Can you please give me some suggestion how to read and print just those characters without using if statement. The only way i know of would be using a Try and except to replace the if statement and read only the last three lines of the file. Any suggestions it would be greatly appreciated.</p> <p>thanks</p>
python
[7]
2,890,095
2,890,096
I want to make a programming notepad in android therefore want to highlight the keywords such as void main ,float etc
<p>I tried to use the addTextChangedListener but want to process the data just entered. So how would I be able to traverse through the content of the edited text so as to track whether a keyword was entered. </p>
android
[4]
2,177,522
2,177,523
Registering with Facebook Account
<p>I have a website with custom login and registration page. Everything working fine. Now I would like to get the member's data from Facebook, like first name, last name, email, dob, gender, picture and place to simplfy registration process..</p> <p>I created app account in Facebook and got appID and canvas url also.</p> <p>I am looking for a FB connect button, when user clicks on the button, it should authenticate FB account and retrive data from Facebook.</p> <p>Give me some sample code.</p>
asp.net
[9]
5,956,365
5,956,366
Any advantages of hover over mouseover in JQuery?
<p>I am fairly new to JQuery API. I have been using mouseover, but I have never used hover before. SO I am wondering if I should use hover instead.</p>
jquery
[5]
1,521,073
1,521,074
Interact with websites C++
<p>How do I interact with websites in C++?</p> <p>For example, a website has a dropbox, text area and a button, and I want my program to fill text inside the text area, choose an option from the dropbox, and make the button fire its event("clicking" it).</p> <p>How can I achieve something like that?</p> <p>thanks!</p>
c++
[6]
4,798,386
4,798,387
C++ reference pointing to a temporary variable?
<pre><code>class ClassB { int m_b; public: ClassB(int b) : m_b(b) {} void PrintClassB() const { cout &lt;&lt; "m_b: " &lt;&lt; m_b &lt;&lt; endl; } }; int main(int argc, char* argv[]) { const ClassB &amp;af = ClassB(1); af.PrintClassB(); // print m_b: 1 with vs2008 &amp; gcc 4.4.3 } </code></pre> <p>Given the above code, I have difficulties to understand this snippet:</p> <p>Q1> What does this line mean?</p> <pre><code>const ClassB &amp;af = ClassB(1); </code></pre> <p>Here is my understanding:</p> <blockquote> <pre><code>af refers to a temporary variable ClassB(1) and after the </code></pre> <p>execution of this line, the temporary variable is destroyed and af refers to an undefined variable. During this procedure, no copy-constructor is called.</p> </blockquote> <p>Then why we can still issue the following statement and obtain the results?</p> <pre><code>af.PrintClassB(); // print m_b: 1 with vs2008 &amp; gcc 4.4.3 </code></pre>
c++
[6]
3,304,065
3,304,066
services \ remote service
<p>sorry for a newbie question.. but "Service" by it's defenision meaning the same as "Remote service" in Android?</p> <p>and if not, what is the diffrence between them?</p> <p>thanks,</p> <p>moshik.</p>
android
[4]
3,277,657
3,277,658
Correct method for instantiating object from String containing class name (with known superclass)
<p>I am trying to create new instances of a class (specifically a subclass of an abstract class) by using the forName(String) method.</p> <p>For example, if I wanted a subclass of Number:</p> <pre><code>import static java.lang.Class.forName; import java.lang.reflect.Constructor; Object[] arguments = new Object[] {0}; String classname = "java.lang.Integer"; try { Class&lt;? extends Number&gt; c = forName(classname).asSubclass(Number.class); Constructor&lt;? extends Number&gt; constructor = c.getConstructor(Number.class); Number x = constructor.newInstance(arguments); } catch (Exception e) { e.printStackTrace(); } </code></pre> <p>What am I doing wrong?</p> <p>EDIT: Stacktrace</p> <pre><code>java.lang.NoSuchMethodException: java.lang.Integer.&lt;init&gt;(java.lang.Number) at java.lang.Class.getConstructor0(Unknown Source) at java.lang.Class.getConstructor(Unknown Source) </code></pre>
java
[1]
3,991,274
3,991,275
Adding a number to a word to call up a variable
<p>Please be nice I am a total newby.</p> <p>I have a list of variables (strings) from num1 to num90. I need to call these from a function by adding the number in an int to the word num.</p> <p>The task is to convert digits to words from 'jumping into c++'...I might not be going about it in the 'right' way but this part has been stopping me for a while now!!</p> <p>I'm trying like this:</p> <pre><code> #include &lt;iostream&gt; #include &lt;string&gt; using namespace std; // Hard code numbers to 20 and then in tens to 90 string num1 = "one"; string num2 = "two"; string num3 = "three"; string num4 = "four"; string num5 = "five"; string num6 = "six"; string num7 = "seven"; string num8 = "eight"; string num9 = "nine"; </code></pre> <p>Etc...up to 90</p> <pre><code> int main () { // Break the number down into three digit blocks int num = 0; cout &lt;&lt; "Please enter the number: "; cin &gt;&gt; num; while (num &gt; 999) { int digit = (num % 1000); num = ((num - digit)/1000); //cout &lt;&lt; digit &lt;&lt; '\n'; //cout &lt;&lt; num &lt;&lt; '\n'; // For each block of numbers work out hundreds, if (digit &gt; 100) { int i = digit; int j = (i % 100); cout &lt;&lt; num.append(j) &lt;&lt; " hundred"; } </code></pre> <p>What I need to happen is the number stored in 'j' to be tagged onto the word num in order to call the string num*.</p> <p>Is this possible?</p>
c++
[6]
3,369,046
3,369,047
csharp method word first and last letter
<p>i have method, which have parameter "word" returns Word first and the last letter with string. between first and last letter there is three points. example when you write "stackoverflow" it returns it like that "s...w"</p> <p>I have this code but i wont work.</p> <pre><code>namespace stackoverflow { class Program { static void Main(string[] args) { string word = "stackoverflow"; string firsLast = FirsLast(word); Console.WriteLine(firsLast); Console.ReadKey(); } private static string FirsLast(string word) { string firsLast = "..."; for (int i = 0; i &lt; word.Length; i += 2) { firsLast += word.ElementAt(i); } return firsLast; } } } </code></pre>
c#
[0]
5,960,217
5,960,218
Preventing any Activity from vanish while intent from activty to activity
<p>in my project i have a several activities.. but i have a one (parent) activity... from that activity i intend to other activities for getting data from other activities.. my problem is while indent back to my parent activity all details entered before were gone...can any one assist me how preserve those data's... thanks in advance..</p>
android
[4]
199,086
199,087
Reading(?) escape chars
<p>I'm trying to read a .php file and replace the hex'd chars. The php file is of the following format:</p> <pre><code>&lt;?php ${"\x47\x4c\x4f\x42\x41\x4cS"}["\x6ana\x76\x79\x77\x70\x74\x62x"] ... ?&gt; </code></pre> <p>The problem is that it messes up the escape chars ( \" )</p> <p>My code so far:</p> <pre><code>while(i&lt;=filelen) { if(str[i]=='\\' &amp;&amp; str[i+1]=='x' &amp;&amp; (str[i+2]&gt;=48 &amp;&amp; str[i+2]&lt;=57 || str[i+2]&gt;=97 &amp;&amp; str[i+2]&lt;=122) ) { string temp(str.substr(i,4)); stringstream k; temp.erase(0,2); string temp2; temp2=hexToAscii(temp[0],temp[1]); output.append(temp2); i+=4; } else { stringstream k; k&lt;&lt;str[i]; output.append(k.str()); i++; } } </code></pre> <p>Any ideas?</p>
c++
[6]
2,287,859
2,287,860
Python method return. Interpreter bug?
<p>I had a method like this:</p> <pre><code>def _play(self): carda = self._carda cardb = self._cardb if carda.is_trump and cardb.is_trump: winner = self._winbyrank() return winner if not carda.is_trump and not cardb.is_trump: if carda.suite == cardb.suite: winner = self._winbyrank() return winner else: winner = self._winbyfirst() return winner if carda.is_trump and not cardb.is_trump: winner = self._winbytrump() return winner elif not carda.is_trump and cardb.is_trump: winner = self._winbytrump() return winner </code></pre> <p>This was <strong><em>occasionally</em></strong> (and to me unpredictably) returning <code>None</code>. When I replaced it with the following it fixed the problem. </p> <pre><code>def _play(self): carda = self._carda cardb = self._cardb if carda.is_trump and cardb.is_trump: winner = self._winbyrank() if not carda.is_trump and not cardb.is_trump: if carda.suite == cardb.suite: winner = self._winbyrank() else: winner = self._winbyfirst() if carda.is_trump and not cardb.is_trump: winner = self._winbytrump() elif not carda.is_trump and cardb.is_trump: winner = self._winbytrump() return winner </code></pre> <p>Isn't this a bug in the Python interpreter? Shouldn't the method <code>return</code> the <code>winner</code> value and exit the method rather than still moving 'till the end and returning <code>None</code>? I'm using Python 2.7.3</p>
python
[7]
3,396,972
3,396,973
javascript: Implementing selection via click, control click and shift click, such as in windows explorer
<p>In Javascript: </p> <p>I need to implement selection via click, control click and shift click on rows in an html table, such as in windows explorer, and I hate to write it if the code already exists.</p> <p>Can anyone point me in the right direction?</p> <p>thanks!</p>
javascript
[3]
438,603
438,604
jquery detect the url to which something will get redirected
<p>I have a window.onbeforeunload function, and I want to detect where I will get redirected to...</p> <p>any ideas?</p> <p>Markus</p>
jquery
[5]
2,497,327
2,497,328
PayPal Donations on Android Apps
<p>I am currently developing an application where I want to be able to have an option to allow the user to donate money for the app. Is there a particular way about doing this for android. I have tried looking at google but it mainly shows about paypal donation buttons for websites</p>
android
[4]
1,940,890
1,940,891
Run bash scripts from JAVA and return the results
<p>I am attempting to get output of a shell / bash script, that is run from a JAVA program, although I am not having much luck, the code is as follows:</p> <pre><code>GetStats(winhostname); public static String winhostname "cmd /c hostname"; public static void GetStats(String operation) { try { Process p=Runtime.getRuntime().exec(operation); p.waitFor(); BufferedReader reader=new BufferedReader(new InputStreamReader(p.getInputStream())); String line=reader.readLine(); while(line!=null) { System.out.println(line); if (operation.equals("winhostname")) { winhostnamevalue = line; } line=reader.readLine(); } } catch(IOException e1) {} catch(InterruptedException e2) {} } </code></pre> <p>This works on Windows fine, so I changed the value of winhostname to "sh namecheck.sh" (which simply echos the hostname) and the shell script is located in the same directory as the java / class file. Although when run I get a blank result, not null, just blank.</p>
java
[1]
2,793,795
2,793,796
How do I select multiple values from a drop down and read those values?
<p>How do I implement selecting multiple values from a drop down and read those values?</p>
java
[1]
3,116,479
3,116,480
Tuple to string
<p>I have a tuple.</p> <pre><code>tst = ([['name', u'bob-21'], ['name', u'john-28']], True) </code></pre> <p>And I want to convert it to a string..</p> <pre><code>print tst2 "([['name', u'bob-21'], ['name', u'john-28']], True)" </code></pre> <p>what is a good way to do this?</p> <p>Thanks!</p>
python
[7]
4,819,336
4,819,337
how to find daily visitors of website using php
<p>i want to know that how to find approximate visitors and daily earning of website using php.</p> <pre><code>$value=$alexa.".".$random_number; </code></pre> <p>my current algorithm is using alexa and one random number .</p> <p>so any idea what could be best algorithm and possible factors that effect it.</p>
php
[2]
4,764,410
4,764,411
Not sure how to use jQuery "live" from version 1.7
<p>Here a small snippet to show/hide text. The problem is that the click event doesn't fire for the "readless" class. Usually I would have use the "live" function of jQuery, but since its being deprecated in favor of "on", I wonder how should I do it?</p> <p>Here's A jsfiddle: <a href="http://jsfiddle.net/SSAu2/" rel="nofollow">http://jsfiddle.net/SSAu2/</a></p> <p>code:</p> <pre><code>$(document).ready(function(){ var showHiddenText = function(e){ e.preventDefault(); var $this = $(this); $this.prev().fadeIn(); $this.text("less").removeClass("readmore-anchor").addClass("readless-anchor"); }; var hideShownText = function(e){ e.preventDefault(); var $this = $(this); $this.prev().fadeOut(); $this.text("more").removeClass("readless-anchor").addClass("readmore-anchor"); }; $(".readmore").after("&lt;a href='#' class='readmore-anchor'&gt;More&lt;/a&gt;"); $(".readmore-anchor").on("click", showHiddenText); $(".readless-anchor").on("click", hideShownText); });​ </code></pre>
jquery
[5]
1,233,499
1,233,500
Jquery Parent Item of Div containing X content
<p>I need to add a CSS class to the TR (or multiple TR's) of the parent of a TD containing some specific text. </p> <p>Because of the CMS I can't control the code, but I can add some Jquery and CSS.</p> <p>I've tried a few things, but I've had no luck.</p> <p>Here is an example of what I had in mind.</p> <pre><code>&lt;style&gt; tr.highlight { background: Blue;} &lt;/style&gt; &lt;table&gt; &lt;tr&gt; &lt;td&gt; Pet &lt;/td&gt; &lt;td&gt; Number of Legs &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; Cat &lt;/td&gt; &lt;td&gt; 4 &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; Doggie &lt;/td&gt; &lt;td&gt; 4 &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p>And I essentially want the jquery to add that class (highlight) to the offending TR.</p> <p>** I know this is not an ideal approach, but desperate times call for desperate measures. **</p> <p>Thanks for your help.</p>
jquery
[5]
2,889,083
2,889,084
php function to determine how much of the total time was at night
<p>I have two variables, a start hour and an end hour.</p> <p>I need to determine which part of that is between 06:00 and 19:00 (morning time) or how long the time between them is at night (19:00 to 06:00)?</p>
php
[2]
3,506,803
3,506,804
How to shutdown an android mobile programatically?
<p>Is it possible to shutdown the mobile programatically. that is with out using su commands..</p>
android
[4]
3,452,761
3,452,762
Error--->ASP.net website Administration tool .Please help me i can't create role, user and so on
<blockquote> <p>Unable to connect to SQL Server database. at System.Web.Administration.WebAdminPage.CallWebAdminHelperMethod(Boolean isMembership, String methodName, Object[] parameters, Type[] paramTypes) at ASP.security_roles_manageallroles_aspx.BindGrid() at ASP.security_roles_manageallroles_aspx.Page_Load() at System.Web.Util.CalliHelper.ArglessFunctionCaller(IntPtr fp, Object o) at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) at System.Web.UI.Control.OnLoad(EventArgs e) at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) </p> </blockquote>
asp.net
[9]
5,218,145
5,218,146
If not declared, declare the variable?
<p>The topic might be a bit cryptic, but here's my problem (perhaps a n00b-thing?):</p> <p>For my site I have a widget, that user can use on their site as such (for example):</p> <pre><code>&lt;script type="text/javascript"&gt; var widget_width ="300"; &lt;/script&gt; &lt;script src="http://something/a.js" type="text/javascript"&gt;&lt;/script&gt; </code></pre> <p>Now, in the .js file I want to check if the user have declared the widget_width variable. So I thought I might do something like (I want the variable to be empty, "", because I do a server-side validation too):</p> <pre><code>if(typeof widget_width == 'undefined') { var widget_width = ""; } </code></pre> <p>This didn't work, neither did:</p> <pre><code>if(!widget_width) { var widget_width = ""; } </code></pre> <p>Any ideas on how do declare a variable when needed this way? </p>
javascript
[3]
5,389,543
5,389,544
Javascript CR+LF will break string?
<p>When storing '\n\r' inside a string constant it will make the Javascript engine throw an error like "unterminated string" and so on.</p> <p>How to solve this?</p> <p>More info: basically I want to use Javascript to select text into a TEXTAREA HTML field and insert newlines. When trying to stuff those constants, I get an error.</p>
javascript
[3]
3,455,113
3,455,114
tracking user logins per day
<p>hey guys i'm running a script on my site: as a user logs into my website i write this days date into a text file so i can know at witch days the user was active on my website. the thing is, if a user lets say didn't log out from the site for 2 days or more how can i check if he was on the site on those days? can some one give me a good suggestion?</p> <p>here is the code i'm running as part of my login, just before i register the session: (by the way ill be glad to hear if there's a better way to do it?) </p> <pre><code> $log_file_name = "logfile.txt"; $log_file_path = "log_files/$id/$log_file_name"; if(file_exists($log_file_path)){ $not = ""; $todaydate = date('d,m,Y'); $today = "$todaydate;"; $strlength = strlen($today); $file_contents = file_get_contents($log_file_path); $file_contents_arry = explode(";",$file_contents); if(!in_array($todaydate,$file_contents_arry)){ $append = fopen($log_file_path, 'a'); $write = fwrite($append,$today); //writes our string to our file. $close = fclose($append); //closes our file } else if(in_array($todaytodaydate,$file_contents_arry)){} } else{ mkdir("log_files/$id", 0700); $todaydate = date('d,m,Y'); $today = "$todaydate;"; $strlength = strlen($today); $create = fopen($log_file_path, "w"); $write = fwrite($create, $today, $strlength); //writes our string to our file. $close = fclose($create); //closes our file } </code></pre>
php
[2]
2,916,046
2,916,047
PHP: Making a simple screen transition Dashboard
<p>im planning to make a Simple Screen transition Dashboard. I am going to make several stored procedures that returns columns to be displayed between transitions.</p> <p>My question is what would be the best way to do this in PHP, since this is the only accessible language to be used with MSSQL and that doesnt need license. </p> <p>I was thinking to make a hidden Pane(Frame) that handles the delay and loop that loads the Main Page. But im worried that between transition it will take time to Load and might not be a good presentation.</p> <p>Any tips?</p> <p>Sorry.. Simple Screen Transition.. Ex. First page, shows columns (customer, number of transactions, total sales) Second Page, Pie Chart of Last Month vs This Month Third Page, shows columns (seller, number of transactions, total costs ) Fourth Page, shows the Bargraph of Costs for this years months vs last years months and so on.. like 10 of like this.</p> <p>I was adviced on making like an advertisement of sort. Like an Infinite Loop of Power Point presentation that does real time query as the Data is updated every minute.</p> <p>Hope I did some clarifications, if it didnt please let me know.</p> <p>FYI. The client PC that will handle this will only have the local webserver ( i will use xampp) and will connect to MSSQL thru network, they wont have access to the internet for security reasons that I dont know.</p>
php
[2]
2,095,209
2,095,210
os.getcwd() throws Exception
<p>I have situation when the current directory becomes invalid (ie, when some program deletes it). My Python script calls <code>os.getcwd()</code> which terminates with following exception</p> <p><code>OSError: [Errno 2] No such file or directory</code></p> <p>Ideally, it my script would automatically cd into parent directory in such situation. When is the recommended strategy for implementing this?</p> <p>Note, if I try <code>ls</code> from the shell, I get <code>ls: cannot open directory .: Stale NFS file handle</code></p>
python
[7]
4,695,182
4,695,183
How to collapse the section when user click on the header of the section in UITableView?
<p>IS there an easier way to animate the table view. All the rows in my table view change when the user clicks the tab on header of the section of the table view.</p>
iphone
[8]
2,708,145
2,708,146
Store ArrayList in Android after app closes
<p>I have an ArrayList of Strings from which I am drawing a ListView. In the app, the user can add items to the ArrayList, causing an item to be displayed on the ListView. While the app is running, the ArrayList retains its items, but after a reboot (or any other time when the app stops) the items are lost. I've read about internal, external, and SQLite storage, but I couldn't get internal nor external storage to work, and I know nothing about SQLite and the app is due Friday. Is there a better implementation of saving? I've attached a complete copy of the code without any storage methods for review.</p> <p>Thanks.</p> <p><a href="http://www.mediafire.com/?tf8093g39jv0f61" rel="nofollow">http://www.mediafire.com/?tf8093g39jv0f61</a> &lt;-- code</p>
android
[4]
1,615,830
1,615,831
Am I allowed to pass an integer pointer to a function that takes an integer array as an argument in c++?
<p>Probably a stupid question to ask, but seeing as how I'm new here, and this question has to do with a project I'm working one, I'm sure it wouldn't hurt to ask. Many thanks to whosoever answers.</p>
c++
[6]
1,373,874
1,373,875
To add sub-menus to Menu button in android
<p>I want to add action on clicking the Menu button on Android device. Suppose user is seeing Graph (one activity) now and he wants to switch to Charts. When user clicks the Menu button it has to show submenu say "Chart" this will be another activity. and then the user will switch to Charts. How i can accomplish with this? can anybody guide me?</p>
android
[4]
3,754,307
3,754,308
Masterpage width
<p>I have a question for you. In my asp page, the contentplaceholder is too narrow. I created a table with width="100%" but it still narrow. How can I expand it so then it can cover the whole page. I am not allowed to edit the masterpage.</p>
asp.net
[9]
606,549
606,550
What is Context in Android
<p>I have a question regarding the term 'context' in Android. I see that the context provides information about the environment the application runs in, however what is the difference between Application Context and Activity Context? </p> <p>AND why do I do things like this:</p> <pre><code>AlertDialog.Builder dialog = new AlertDialog.Builder(mContext); </code></pre> <p>Why do I pass the context into the constructor? Can anyone provide please help me understand what a context is, and what the context object is?</p> <p>I do not want copy/paste from android Reference since I already have read it.....too many times without understanding.</p>
android
[4]
274,832
274,833
Java class confusion
<p>I am quite new to programming in Java, but I have some experience in c/c++, I am noticing some unwanted behaviour in some of my code, and I am just wondering how to fix it.</p> <p>This is what I have:</p> <pre><code>List&lt;State&gt; list = new ArrayList&lt;State&gt;(); State cur = new State(); cur.x = 1; cur.y = 1; list.add(cur); cur.x = 2; cur.y = 3; list.add(cur); cur.x = 3; cur.y = 4; list.add(cur); for (State i : list) System.out.println(i.x + " " + i.y); class State { public int x = 0; public int y = 0; } </code></pre> <p>This gives me an output of: 3 4 3 4 3 4</p> <p>Where as I want the output to be: 1 1 2 3 3 4</p> <p>How do I fix this? Thanks, paintstripper</p>
java
[1]
4,578,326
4,578,327
PHP - is there any way to quickly parse such text?
<p>In PHP is there any quick way to get the names and values from this?</p> <pre><code>&lt;!--AUTHCODE=VITAL5--&gt;&lt;!--szSerialNumber=111222333444--&gt;&lt;!--szTransactionAmount=1900--&gt;&lt;!--szAuthorizationDeclinedMessage=--&gt;&lt;!--szAVSResponseCode=N--&gt;&lt;!--szAVSResponseMessage=Card authorized, no address or zip code match.--&gt;&lt;!--szOrderNumber=1--&gt;&lt;!--szAuthorizationResponseCode=000067--&gt;&lt;!--szReturnCode=1--&gt;&lt;!--szCVV2ResponseCode=--&gt;&lt;!--szCVV2ResponseMessage=--&gt;&lt;!--szIsApproved=1--&gt;&lt;!--szTransactionFileName=9802850951761.009--&gt;&lt;!--szCAVVResponseCode=--&gt; </code></pre>
php
[2]
1,081,488
1,081,489
Format number in PHP
<p>I would like to format number with decimal places to format without decimal places, example: 146.5 to 146500000. How can i achieve this in PHP? Thank you.</p>
php
[2]
931,076
931,077
getting line-numbers that were changed
<p>Given two text files A,B, what is an easy way to get the line numbers of lines in B not present in A? I see there's difflib, but don't see an interface for retrieving line numbers</p>
python
[7]
2,376,055
2,376,056
xml files in drawable directory? Surely some mistake?
<p>I am attempting to get and advertisers system incorporated into my android app. There are a selection of files (within a tree of directories) that I have been instructed to copy into my projects resources folder. Most of the files &amp; directories make sense... except for the fact that inside their "drawable" directory they have a selection of XML files (along with the expected PNG files). To me this looks like a cock-up. Surely all the XML files should be within the "layout" directory?</p>
android
[4]
2,503,017
2,503,018
Uploading multiple file upload using PUT request
<p>I am trying to upload files in CHUNKS using PUT request using Jquery to PHP server. I have created code where I am able to Upload the chunk file. But something weird is happenening when I try to read it using "php://input"</p> <pre><code>&lt;?php $headerArray=getallheaders(); $filename="d/".$headerArray["filename"]; $length=$headerArray["Content-Length"]; /* PUT data comes in on the stdin stream */ echo "filename".$filename; echo "Chunksize Uploaded:".$length; $putdata = fopen("php://input", "r"); /* Open a file for writing */ $fp = fopen($filename, "a"); while ($data = fread($putdata, $length)) fwrite($fp, $data); /* Close the streams */ fclose($fp); fclose($putdata); echo "FileSize After write : ".filesize($filename); ?&gt; </code></pre> <p>Here I am able to successfully upload the file in chunks when I am sending each chunk one by one and waiting for code to write that chunk to file.</p> <p>But when I do the concurrent uploads(Do not wait for the first chunk to be written in the file ) .. data in the "php://input" seems got overwritten by the next request.</p> <p>I have doble checked the javascript. So the problem is at php end "how should i read the CHUNKS?".</p> <p>I have gone through the follwing link and several other links: <a href="http://php.net/manual/en/features.file-upload.put-method.php" rel="nofollow">http://php.net/manual/en/features.file-upload.put-method.php</a></p> <p>Can somebody help me to understand how php://input works when it recives multiple request at the same time .. does data gets overwritten or the data gets QUEUED in STDIN?</p>
php
[2]
4,814,419
4,814,420
Prevent clicking outside a range of columns in a table
<p>What I'm trying to do is that a user can only click on specific columns in a table. In the example in the fiddle for example only on the 2nd till the 15th column. The first two weeks in a time registration module.</p> <p>I was trying with :lt() function but that only works on the first row it seems.</p> <p><a href="http://jsfiddle.net/KvdM/FxmbB/1/" rel="nofollow">http://jsfiddle.net/KvdM/FxmbB/1/</a></p>
jquery
[5]
284,520
284,521
Wifi Error: Invoking mWifiStateMachine.setWifiEnabled
<p>I am using BroadcastReceiver to get the data form server using wifi, as far as wifi is on every thing working fine for me.In the code, i am using WifiManager mWIFI_MANAGER= mWIFI_MANAGER.setWifiEnabled(true); to start wifi programatically. This specific situation i am getting force close, Error is:Invoking mWifiStateMachine.setWifiEnabled.with out any modification in the code, If i open application again it is working fine. Here my Question is, 1) How to make my activity stable in wifi state changes. 2) Is their any Call back method in the activity in the specific situation.</p> <p>any suggestions or code samples are requested..thanks in advance </p>
android
[4]
583,233
583,234
Running an Activity a certain interval before going to sleep
<p>I am currently working on customizing an Android system and would like that, a few minutes before going to sleep, a given Activity is run, with the same premises as the sleep function (e.g. if the user performs any action, its timer gets reset).</p> <p>For instance, let's say that we set its timer to 5 minutes and the device is set to go to sleep after 10 minutes. This means that, as long as there is no user input (or wakelocks acquired etc.), after 5 minutes my Activity is started, and after another 5 minutes the device enters sleep mode (think of it similar to a screensaver).</p> <p>My initial searches have lead me to the PowerManagerService class, where the ACTION_SCREEN_OFF is broadcast, but the general idea of the code there has so far eluded me.</p> <p>Any help would be appreciated. Thank you.</p>
android
[4]
2,133,429
2,133,430
how to get authentication device token in android
<p>how can we generate authentication token from android device I know how to recover the single token of a android smartphone for notification</p> <p>I find example on the internet, but for the iphone development</p> <p>i find this code </p> <pre><code> def getAuthToken () { StringBuilder builder = new StringBuilder(); builder.append("Email=").append("developer email"); builder.append("&amp;Passwd=").append("password"); builder.append("&amp;accountType=GOOGLE"); builder.append("&amp;source=Google-C2DM-Example"); builder.append("&amp;service=ac2dm"); // Setup the Http Post byte[] data = builder.toString().getBytes(); URL url = new URL("https://www.google.com/accounts/ClientLogin"); HttpURLConnection con = (HttpURLConnection) url.openConnection(); con.setUseCaches(false); con.setDoOutput(true); con.setRequestMethod("POST"); con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); con.setRequestProperty("Content-Length", Integer.toString(data.length)); // Issue the HTTP POST request OutputStream output = con.getOutputStream(); output.write(data); output.close(); // Read the response BufferedReader reader = new BufferedReader(new InputStreamReader(con.getInputStream())); String[] split1 = reader.readLine().split("="); String[] split2 = reader.readLine().split("="); String[] split3 = reader.readLine().split("="); // Finally get the authentication token String clientAuthToken = split3[1]; return clientAuthToken; </code></pre>
android
[4]
3,855,183
3,855,184
MediaStore.Video.Thumbnails.getThumbnail() returns null
<p>I have the following code;</p> <pre><code>String[] projection = { MediaStore.Video.VideoColumns._ID, MediaStore.Video.VideoColumns.DATA }; //String selection = MediaStore.Video.VideoColumns.KIND + "=" + MediaStore.Video.VideoColumns.; String sort = MediaStore.Video.VideoColumns._ID + " DESC"; Cursor myCursor = getActivity().managedQuery(MediaStore.Video.Thumbnails.EXTERNAL_CONTENT_URI, projection, null, null, sort); try { myCursor.moveToFirst(); Log.d("VIDEO_URI", intent.getDataString()); Bitmap bitmap = MediaStore.Video.Thumbnails.getThumbnail( getActivity().getContentResolver(), myCursor.getLong(myCursor.getColumnIndexOrThrow(MediaStore.Video.VideoColumns._ID)), MediaStore.Video.Thumbnails.MICRO_KIND, (BitmapFactory.Options) null ); ImageView iv = (ImageView) getActivity().findViewById(R.id.attached_media_image); //Log.d("IMAGE", curThumb.toString()); iv.setImageBitmap(bitmap); } catch (Exception e) { // TODO: handle exception Log.e("ERROR", e.toString()); } </code></pre> <p>I get the following in my LogCat when this is ran;</p> <pre><code>03-13 12:05:14.740: D/VIDEO_URI(7269): content://media/external/video/media/474 </code></pre> <p>But it doesn't set the image of the iv to anything, and when I try to run the Log.d("IMAGE", curThumb.toString()); line, that is commented out in this example, it throws a null exception.</p> <p>Any help would be much appreciated thank you.</p>
android
[4]
3,245,901
3,245,902
Print 1 to 10 without any loop in java
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/2044033/display-numbers-from-1-to-100-without-loops-or-conditions">Display numbers from 1 to 100 without loops or conditions</a> </p> </blockquote> <p>Interview question:</p> <p>Print 1 to 10 without any loop in java.</p>
java
[1]
5,402,204
5,402,205
javascript / ajax question
<p>I'm wondering if anyone knows a javascript library where I could remotely login to a site, then browse pages upon logging in.</p> <p>This is very easy with php's curl but I'm wondering if there is a javascript equivalent where I can execute multiple remote url's under a single http session.</p> <p>Basically what I'm looking to do is post a username/password to one of my sites and then immediately post some other commands to a different url (same remote domain) using the authenticated session.</p> <p>I haven't come across anything like this yet so I'm wondering if anyone can point me in the direction (if it's even possible). Can definitely be HTML5.</p>
javascript
[3]
4,117,847
4,117,848
Hour to Minutes 00:00 to 00 javascript
<p>I need to convert hours:minutes (00:00) to minutes 00 in Javascript. </p> <p>I thought about doing it by using substr to get hour and minutes separately and then multiply the hours part by 60 and then add the minutes part.</p> <p>Is there any other easy way to do this?</p>
javascript
[3]
5,886,723
5,886,724
Can setTimeout be too long?
<p>I am creating an app that polls the server for specific changes. I use a self calling function using setTimeout. Something like this basically:</p> <pre><code>&lt;script type="text/javascript"&gt; someFunction(); function someFunction() { $.getScript('/some_script'); setTimeout(someFunction, 100000); } &lt;/script&gt; </code></pre> <p>In order to make this polling less intensive on the server, I want to have a longer timeout interval; Maybe somewhere within the 1min to 2min range. Is there a point at which the timeout for setTimeout becomes too long and no longer works properly?</p>
javascript
[3]
1,189,024
1,189,025
objective-c programming - table view display
<p>I am an iPhone developer struggling with one problem for the last three days: there is a text file in the URL: <a href="http://www.amfiindia.com/spages/NAV0.txt" rel="nofollow">http://www.amfiindia.com/spages/NAV0.txt</a>, which contains the Mutual Fund Names and their respective schemes. </p> <p>What I was asked to do is to display the all Mutual Fund names only in the table view and if we click on the any Mutual Fund name in the rows of a table view, it must show the Mutual Fund schemes in the next view. </p>
iphone
[8]
1,394,751
1,394,752
how to get position of bitmap inside canvas?
<p>i have a canvas and an image inside canvas.i need know the position of the bitmap inside the canvas. in my case x and y are not static values.how to hide this image while touch on it? what is the advantage of using SurfaceView over View.Here i am using view.</p> <pre><code>public void onDraw(Canvas canvas) { Bitmap imgtable = BitmapFactory.decodeResource(getResources(),R.drawable.table_01); int x=50; int y=50; canvas.drawBitmap(imgtable, x, y, null); } </code></pre>
android
[4]
2,107,650
2,107,651
Very basic PHP - IF AND IF...?
<p>My current code is as follows:</p> <pre><code>if ( ( $status == 'active' ) || ( $status == 'full' ) ) { </code></pre> <p>I need to also include an AND statement. So if $status is either full or active AND $position matches 'need photo' or 'completed' then it displays. How do I include an AND statement?</p> <p>I tried the following but it didn't seem to work:</p> <pre><code>if ( ( $status == 'active' ) || ( $status == 'full' ) &amp;&amp; ( $position == 'need photo' ) || ( ( $position == 'completed' ) ) { </code></pre> <p>Any help? Thank you! :-) I'm fairly new to all of this. I tried Google but couldn't find a clear answer.</p>
php
[2]
5,701,087
5,701,088
transparent activity make other activities background black
<p>I have a pretty complex main activity that has a button at the bottom that slide up new profile activity. Profile activity has its height set to 70% of screen and a transparent background trough theme.</p> <pre><code>&lt;style name="Theme.Transparent" parent="android:Theme"&gt; &lt;item name="android:windowBackground"&gt;@android:color/transparent&lt;/item&gt; &lt;item name="android:windowIsTranslucent"&gt;true&lt;/item&gt; &lt;item name="android:windowContentOverlay"&gt;@null&lt;/item&gt; &lt;item name="android:windowNoTitle"&gt;true&lt;/item&gt; &lt;item name="android:backgroundDimEnabled"&gt;false&lt;/item&gt; &lt;item name="android:windowAnimationStyle"&gt;@style/ProfileDialogAnimation&lt;/item&gt; &lt;/style&gt; </code></pre> <p>If I don’t open profile activity and I navigate through my application everything is working as expected, except when I come back and open profile activity it’s not transparent but have a background (image) the same as other activities. Second test (after force stopping application trough application manager, if I just close application behavior is the same).</p> <p>If I open profile activity right away the transparency is working as it should, but when I open another activity with image for background, instead of image I see black background. If the activity has a solid color background it’s displayed correctly.</p> <p>If I remove transparency stuff from my custom theme (those two lines) </p> <pre><code> &lt;item name="android:windowBackground"&gt;@android:color/transparent&lt;/item&gt; &lt;item name="android:windowIsTranslucent"&gt;true&lt;/item&gt; </code></pre> <p>Everything is working ok. (Obviously profile activity is not see trough) So basically if I navigate to activity with transparent background, set trough theme, all other activities with image for background are black.</p> <p>I know it’s a long shot thinking you could help me with so little data, but keeping my fingers crossed. </p>
android
[4]
4,336,684
4,336,685
"UnHover" Moved Elements with jQuery
<p>I'm using jQuery to move an element to a different position on the page when I click on it. The element is in a "hovered" state because the cursor is over it when I click it. When the element gets to it's new postion it retains it "hovered" state. How can I clear it?</p>
jquery
[5]
3,113,370
3,113,371
I need to extract email addresses from yahoo full headers and need help matching them
<p>I have several thousand emails saved in a directory. These emails are opened with file_get_contents. I need to match all reply-to: emails from these headers. How do I match them?</p>
php
[2]
4,503,756
4,503,757
How to click on Android Button then go to google play apps
<p>I wonder how to make a android button can click and redirect user to google play.</p> <p>Example: I want send user to android apps(https://play.google.com/store/apps/details?id=com.theopen.android) after user click on Button in my activity.</p> <p>How to do this?</p> <p>Regards,</p>
android
[4]
5,598,165
5,598,166
Get the list of questions who has unchecked Radio buttons on a page JQuery
<p>I have 10 questions on my page and each question has a <strong>Radio button Group (Yes, No)</strong>. I am trying to get the list of questions who has <strong>unchecked Radio buttons</strong> on the page on the click event of <strong>Continue</strong> Button .</p> <pre><code> $('#btnContinue').click(function () { var result = ''; if ($(":radio:checked").size() &lt; 10) { $(":radio:!checked").each(function () { result += "," + $(this).val(); }); alert(result); } }); </code></pre> <p>doesn't give me the required result. Please advice.</p> <p>Thanks in advance</p> <p>BB</p>
jquery
[5]
3,485,299
3,485,300
Draw a straight line with java's graphic class
<p>I need to draw a line from two points and what I did so far is using <code>drawLine(x1,y1,x2,y2)</code>. But what I want to do is draw a line that intersects with these two points <code>(x1,y1)</code> and <code>(x2,y2)</code>. </p> <p>I don't want to <em>just</em> draw a line between them, here's an image of what I have and what I want to do:</p> <p><img src="http://i.stack.imgur.com/jgJt4.jpg" alt="Line Drawings"></p>
java
[1]
2,467,067
2,467,068
How to skip a iteration/loop in while-loop
<p>Is there an elegant way to skip a iteration in while-loop ?</p> <p>What I want to do is</p> <pre><code> while(rs.next()) { if(f.exists() &amp;&amp; !f.isDirectory()){ //then skip the iteration } else { //proceed } } </code></pre>
java
[1]
5,240,235
5,240,236
Android Subscription based Licensing
<p>Currently readying an app for release onto the marketplace. The big wigs want to charge a subscription for the app and this is proving troublesome to implement for android.</p> <p>We don't want to do "99 cents buys the app forever" since there is an ongoing server usage for this app and so we want to charge a subscription. </p> <p>Seems that Android Licensing Server doesn't support this - all that does is "did I buy this app or not" to help reduce piracy.</p> <p>I also do not want to go down the route of having extra versions installed that act as the purchase. Otherwise the user would be buying an app every year.</p> <p>Is there some solution I am missing ?</p>
android
[4]
4,796,317
4,796,318
HTML Checkbox says that it is checked/unchecked but it is not
<pre><code>if($(this).prop('checked', true)){ $(this).prop('checked',false); console.log('its checked yo'); } else if(!$(this).is(':checked')){ $('[type=checkbox]').prop("checked", false); $(this).prop('checked', true); console.log("Well this certainly isn't checked"); } } </code></pre> <p><a href="http://jsfiddle.net/bkj8n/2/#run" rel="nofollow">http://jsfiddle.net/bkj8n/2/#run</a> So my setup is for a form that adds pricing for different options you select with a checkbox. For this group of items only one option can be selected at a time. So when another item gets selected I uncheck all boxes and then check the one that they pick. I have tried this using .prop() .attr() and more and it hasn't worked. One of three things happens every time.</p> <ol> <li><p>It works and I can only pick one and the others are deselected. BUT: I cannot uncheck that item, and the prices (values) for the other checkboxes are added which means that it thinks they are still checked.</p></li> <li><p>It says they are all checked no matter what.. even if they aren't. So nothing works.</p></li> <li><p>The values are added correctly.. I'm only getting one option at a time and I can click that option again to set it back to zero. BUT: The check mark doesn't show up in the box.</p></li> </ol> <p>This is frustrating me. Thanks!</p>
jquery
[5]
1,599,868
1,599,869
When to use time_nanosleep?
<p>Just stumbled upon <code>time_nanosleep()</code> and started to wonder, when would you ever want to use this?</p> <p>Also, is it even possible to work with such short timespans in a scripting language like PHP?</p>
php
[2]
2,121,978
2,121,979
DialogFragment disappears on rotation despite setRetainInstance(true)
<p>I have a "hello world"-ish sample app that uses the android-support-v4 fragments API. The activity consists of a button, clicking it will show a DialogFragment. However, configuration changes like rotation cause the dialog to vanish, even if setRetainInstance(true) is used.</p> <p>Any idea how to fix this?</p> <p>RetFragment.java</p> <pre><code>package me.local.HelloFroyo; import android.os.Bundle; import android.support.v4.app.*; import android.util.Log; import android.view.*; public class RetFragment extends DialogFragment { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setRetainInstance(true); } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { return inflater.inflate(R.layout.hello_dialog_fragment, container); } @Override public void onDestroy() { super.onDestroy(); Log.e("RET", "onDestroy"); } } </code></pre> <p>MainActivity.java</p> <pre><code>package me.local.HelloFroyo; import android.os.Bundle; import android.support.v4.app.FragmentActivity; import android.view.View; public class MainActivity extends FragmentActivity { private static final String TAG_DLG = "myFragDlg"; public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); this.setContentView(R.layout.activity_main); } public void onShowClick(View v) { RetFragment ret = new RetFragment(); ret.show(getSupportFragmentManager(), TAG_DLG); } } </code></pre>
android
[4]
1,392,475
1,392,476
How to prepare list which contains list objects?
<p>I am fetching the records from database and those value like this</p> <pre><code>1,"a" 1,"b" 2,"c" 3,"d" 3,"e" 4,"f" </code></pre> <p>Here I got result into ResultSet now I want to prepare list like</p> <pre><code>[[a,b],[c],[d.e],[f]] </code></pre> <p>Any one can help me how to solve this, I tried with the list and map concept but I am getting last list object only. Thanks</p>
java
[1]
3,399,885
3,399,886
Insert content after two conditional values are met
<p>I really have no idea how to approach this. I've been reading for like 10 hours just about javascript, html, css,if statements, conditionals, etc etc (beginner attempting to learning everything >_&lt;). It's been a ton of fun but I'm rather stuck on how to approach this.</p> <p>Here's what I'm trying to accomplish. I want a user to be able to click 1 of 2 pictures and then have the value of the picture change from 0 to 1....or selected? I then want to do this exact scenario one additional time (so essentially two different input choices). At the end I would like to have content inserted else where on the page via a div if both values are changed from 0 to 1.</p> <p>I also apologize for blatantly being uneducated in regards to my question. I'm doing my best to learn though and I absolutely love trial and error.</p> <p>Edit: This is my first post on this site. You guys are unbelievable. Give me some time to read through all of the comments. I have to look up a lot of what you guys are referencing to fully understand it. </p> <p>Regardless thanks again.</p>
jquery
[5]
3,293,118
3,293,119
asp.net setting validationexpression dynamically
<p>I have several pages in my form where I need to validate Email address. Rather than set validationexpression in each page , I want to store the Regex string in a Constants class as a string constant and do some thing like</p> <pre><code> ValidationExpression="&lt;%=Tickets.App_Code.Constants.EmailRegex%&gt;" </code></pre> <p>I know I can do this in Code Behind but I want to do it declaratively in Aspx page. However the above does not work as the text is not replaced by the contents of the constant. In asp.net we have syntax like <code>&lt;%# %&gt;(Binding) , &lt;%= %&gt; (Invoke code)</code>.</p> <p>I searched the web but I cannot find much documentation on this area. Can somebody help ?</p>
asp.net
[9]
1,937,093
1,937,094
python trying to make a adventure game
<p>I'am trying to make a adventure game where you click on a button (easygui.msgbox) and after you click on one button it would go to a question on which on you clicked (by the way im only 13 years old)</p>
python
[7]
4,103,498
4,103,499
How to make this function not prematurely split?
<p>I've written this function...</p> <pre><code>internal static IEnumerable&lt;KeyValuePair&lt;char?, string&gt;&gt; SplitUnescaped(this string input, char[] separators) { int index = 0; var state = new Stack&lt;char&gt;(); for (int i = 0; i &lt; input.Length; ++i) { char c = input[i]; char s = state.Count &gt; 0 ? state.Peek() : default(char); if (state.Count &gt; 0 &amp;&amp; (s == '\\' || (s == '[' &amp;&amp; c == ']') || ((s == '"' || s == '\'') &amp;&amp; c == s))) state.Pop(); else if (c == '\\' || c == '[' || c == '"' || c == '\'') state.Push(c); if (state.Count == 0 &amp;&amp; separators.Contains(c)) { yield return new KeyValuePair&lt;char?, string&gt;(c, input.Substring(index, i - index)); index = i + 1; } } yield return new KeyValuePair&lt;char?, string&gt;(null, input.Substring(index)); } </code></pre> <p>Which splits a string on the given separators, as long as they aren't escaped, in quotes, or in brackets. Seems to work pretty well, but there's one problem with it.</p> <p>There characters I want to split on include a space:</p> <pre><code>{ '&gt;', '+', '~', ' ' }; </code></pre> <p>So, given the string</p> <pre><code>a &gt; b </code></pre> <p>I want it to split on <code>&gt;</code> and ignore the spaces, but given</p> <pre><code>a b </code></pre> <p>I <em>do</em> want it to split on the space.</p> <p>How can I fix the function?</p>
c#
[0]
3,275,254
3,275,255
Alternative to jQuery .siblings()? .siblings is returning a set including current selected element
<p>I have four div's which were cloned from another 4 div's. The cloned div's have new id's. When one of the new div's is selected and I do $(this).siblings(), I am getting back the 4 new div's instead of 3. I am not sure why this is happening and if cloning messed something up. </p> <p>Is there a way to make siblings work right in my case? Is there a way to select the other 3 div's without using siblings()?</p>
jquery
[5]
5,493,496
5,493,497
PHP: is doing a lot of file_exist() calls disk-intensive?
<p>I want to check a certain directory to see if a file exists, and if it does not, copy the missing file from another directory. Basically syncing two folders. I can do so easily with PHP, using the <code>file_exists()</code> function. However, the directory exists of some 20,000 files, so I feel this could be bad for the hard drive (a lot of reads???). Does this make any sense, or is there nothing to worry about?</p>
php
[2]
2,197,470
2,197,471
How to show newly added (by Javascript) DOM Elements after refresh?
<p>I have a JavaScript function which multiplies a DOM element.</p> <p>I hit it 2 times (for example) and I get 3 Elements like this:</p> <pre><code>&lt;!-- How to show all my new Elements after refresh? --&gt; &lt;tr id="toBeMultiplied"&gt; &lt;td&gt; &lt;!-- How to echo the value of this input? --&gt; &lt;input type="text" name="numbers[]" /&gt; &lt;/td&gt; &lt;td&gt; &lt;!-- How to echo the value of this input? --&gt; &lt;input type="text" name="titles[]" /&gt; &lt;/td&gt; &lt;td&gt; &lt;!-- How to echo the value of this input? --&gt; &lt;input type="text" name="lengths[]" /&gt; &lt;/td&gt; &lt;/tr&gt; </code></pre> <p>But this is just a small part of a big Form! When I click on Submit, those new Elements I've just created disappear.</p> <p>So, I want to <strong>make my new Elements to not disappear</strong>.</p>
php
[2]
5,622,550
5,622,551
How to override a method which is used in the parent constructor?
<p>I'm having a design problem which I don't know how to overcome in java. I want to override a method that is called from the parent constructor. Here is a very simple example of the problem: </p> <pre><code>public class Parent { public Parent(){ a(); } public void a() { // CODE return; } } public class Child extends Parent { public Child() { super(); } public void a() { super.a(); // MORE CODE return; } } </code></pre> <p>I know that the child class wont be initialized until the parent is constructed therefore the childs a() method wont be called. What is the correct design to overcome this problem?</p>
java
[1]
708,492
708,493
Global editable config settings in C#.NET?
<p>I want the best of both worlds: I want to be able to persist changes during runtime, like the User scoped application settings can, and I also want these settings to be global. Is there some way to accomplish this through app.config settings files? Should I look at some other way to persist global, runtime editable settings for my application?</p>
c#
[0]
4,084,570
4,084,571
Check to see if python script is running
<p>I have a python daemon running as a part of my web app/ How can I quickly check (using python) if my daemon is running and, if not, launch it?</p> <p>I want to do it that way to fix any crashes of the daemon, and so the script does not have to be run manually, it will automatically run as soon as it is called and then stay running.</p> <p>How can i check (using python) if my script is running?</p>
python
[7]
1,016,490
1,016,491
How do select a radio button with JavaScript?
<p>I've tried <code>select();</code> <code>check();</code> and even <code>.selected = true;</code> but I still haven't gotten around to selecting that radio button. Is there any way I can accomplish this?</p>
javascript
[3]
4,758,402
4,758,403
How to develop application with embeded Java code editor and compilator?
<p>I am just developing java application, which by the way generates array of data. Let's imagine we have a dynamic array of string. I need to transform that data.</p> <p>My goal is to have java code editor somewhere in GUI, so an user of this application can write java code data transformation. And the user should be able to run that transformation through some button in GUI so it is needed to compile that code.</p> <p>So I need to have java code editor somewhere in my GUI, where user can write transformation code, and then run that code from GUI. </p> <p>Thank you for any ideas.</p>
java
[1]
383,787
383,788
Java 2D game does not work from menu ?
<p>Well i've been developing a 2D java game for a while but i face with a strange problem and i'm stucked :/. So that i'm uploading my source code here.</p> <p>It is an eclipse project, in this project i have included 2 main methods to clearly state the problem i have experienced:</p> <ol> <li><p>in Menu class, starts the system from the menu and menu passes the frame to the game manager after pressing play game button</p></li> <li><p>in GameManager class, starts the system by passing a frame to game manager directly.</p></li> </ol> <p>My problem is that: when i start the system from Menu class and press play game button, rendering continues but system does not respond to any actions even if i had added listeners to canvas, but it works when i start the system from the main method which belongs to GameManager class. :/ </p> <p>here is my source code: <a href="http://www.mediafire.com/?4d2v1jfizrgpaqp" rel="nofollow">http://www.mediafire.com/?4d2v1jfizrgpaqp</a></p> <p>Thanks</p>
java
[1]
3,872,497
3,872,498
Calander Java Script
<p>I have one index.html page and on this page i have three control that is one is for source , second for destination, and third is for date/time. Now i have source-destination like A-B then in calender control there is only certain day of certain month is only available .</p> <p>For example if London-France is only available on only monday from april to december means in calender only monday is enable and all other date are disable.</p> <p>I have lots of this types of source and destination and for all those source and destination this date and day is different ..</p> <p>how can i do this with javascript .......</p> <p>plz help me .... thanks,</p>
javascript
[3]
2,372,705
2,372,706
Sorting item template when programmatically add HeaderText
<p>I have datagrid and inside this grid have template field. I add Header text progr. like this</p> <pre><code>gvData.HeaderRow.Cells(8).Text = "Hi" </code></pre> <p>But when I do this I can not sort this column when add SortExpression="Hi", i not have clickable header.</p> <p>How can I do this</p> <p>Tnx</p>
asp.net
[9]
962,814
962,815
How to save multiple files in bundle in iphone app?
<p>Hi all i am trying to save image in the bundle which i have currently on my view,but the problem is that i can only save one image,if i want to save the another image it replaces the old.I am not getting how to save the multiple images in the bundle then. Here is my code.</p> <pre><code>- (void)writeImageToDocuments:(UIImage*)image { NSData *png = UIImagePNGRepresentation(image); NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSError *error = nil; [png writeToFile:[documentsDirectory stringByAppendingPathComponent:@"image.png"] options:NSAtomicWrite error:&amp;error]; } </code></pre> <p><strong>Please Help me out, how to save multiple images, files e.t.c in bundle</strong></p> <p>Thanks in advance </p>
iphone
[8]
3,262,042
3,262,043
Reinventing the Wheel: the time class
<p>I am trying to reinvent the wheel and I want to create a time class in c++, I do want this class to be dependent of any c/c++ std libraries, why ? because I am writing a small OS for fun, but I can't seem to find to find information regarding how I would start. can anyone lead me in the right direction ? most of the search I find are just how to use a std library to get time... </p> <p>Thanks</p> <p>Sorry let me fix that a small os that is x86 for now.</p>
c++
[6]
3,084,466
3,084,467
iPhone, if possible to get a photo from album without use UIImagePickerController?
<p>as topic, I want iPhone app can access the photo album and got a photo but without popup the UIImagePickerController, does it possible ? </p> <p>thanks for tip </p>
iphone
[8]