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,873,926
5,873,927
Adding up in dict
<pre><code>series[1][2] = 3 val = 7 </code></pre> <p>How can I add <code>val</code> to <code>series[1][2]</code> so that <code>series[1][2]</code> becomes 10? </p>
python
[7]
4,604,160
4,604,161
How to create a macro that throws on verifying HR and also logs?
<p>I have a scenario in the code where the following pattern exist - </p> <pre><code>if (!function(A)) { log("this is the %d error in this file called %s", num, fileName); throw AppException(FUNCTION_ERROR); } </code></pre> <p>the issue with this is you need to do this all the time and the code looks really dirty. so I want to define a macro like - </p> <pre><code>#define VerifyOrThrow(b, retcode, logerror) if (b == 0) \ { \ log(logerror,arg1, arg2) --&gt;this is the issue \ throw(AppException(retcode)); \ } </code></pre> <p>then I can use it like this in a single line</p> <pre><code>VerifyOrThrow(functionA(), FUNCTION_ERROR,this is the %d error in this file called %s); </code></pre> <p>The issue is I am not sure how to define the macro for the variable length argument for the log string.</p> <p>Any ideas?</p>
c++
[6]
3,349,579
3,349,580
doubt Graphics in java
<p>How do I learn graphics programming in Java? Where should I start, and which books would you recommend?</p> <p>Thanks in advance</p>
java
[1]
1,764,549
1,764,550
Beginner problems with many input parameters
<p>Hi I am begginner in C#. I have this class. Class class1 have many variables.</p> <pre><code>class class1 { string variable1; string variable2; //... string variable10 } </code></pre> <p>and class class2 with method doSomethig:</p> <pre><code>class class2 { void doSomething(string s1, string s2, ..., string s10) } </code></pre> <p>I use instace of class1 and class2 in class3.</p> <pre><code>class class3 { class1 obj1 = new clas1(); class2 obj2 = new clas2(); //... string result = obj.doSomething(obj1.variable1, obj1.variable2, ... , obj1.variable10) } </code></pre> <p>Problem is I call in class3 method doSomething from class2 and the input parameters to the method doSomething are variables from class1. I would like have less parameters in method doSomething. I think add variables from class1 in to the struct or in class. What is the best way ? Thank.</p>
c#
[0]
5,870,687
5,870,688
How to call vb script on button click event?
<p>I am trying to call vb script from C#.net on button click event.But it is not working when I am using asp:button contol but when using input type= button working properly.Why this so? I heard that vb script only run in IE not other browser.Does it so?</p>
asp.net
[9]
1,732,935
1,732,936
How to set Wifi wep key, only programmlly?
<p>I have a 40-bit hexadecimal WEP key in the setting of my router. I tried to set the "40-bit hex wep key" in</p> <p>"Wireless &amp; Network"-"Wifi settings"-"Modify network"-"password"</p> <p>but...it seems not work. Although in "Wi-Fi network", it shows this network is "connected" Ping returns "Request timeout"</p> <p>WHERE to set it? or it can only be set in program?<br/></p>
android
[4]
411,227
411,228
Android - Function Normally without simcard
<p>Is there any way to start a phone (Android OS) and make it function normally (of course i understand that no phone/sms services would be available) without any simcard.</p> <p>I mean i just want to start the phone without simcard inserted and make it work normally w.r.t. Apps installed</p> <p>I couldn't find any way to do this or may be i am missing something ?</p> <p>Is there any way to do this ?</p> <p>Yogurt</p>
android
[4]
3,188,924
3,188,925
Pop up box with a timer
<p>After some specified inactivity time (IDLE Time say for 10 mins) the application should give a pop up box with a timer (should display like 60 59 58 ....1), that box should close within 60 secs with cancel option selected and that browser should close if user didint select any option .If the user selects cancel options within 60 secs also it should be closed</p> <p>To appear a pop box i am using <code>setTimeout("pop()",600000);</code> but how to include timer in that atleast that box should close within 60 sec if user doesnt select any option Is there any solution is there Plz help Thanks in Advance, Satya</p>
javascript
[3]
5,275,922
5,275,923
Replacing all text
<p>How would I replace every single word on any given web page client-side with whatever <code>var cms</code> is? It doesn't matter what js dependencies are needed, or if links break.</p>
javascript
[3]
5,336,716
5,336,717
how to display image from path stored in database?
<p>I got the image path inserted in to database by the below code but I'm not able to display it in html page...the path for the images is <code>"images/"</code> how do i display the actual image? i tried hard but the most i got to work was to display the file name not the image.</p> <pre><code>&lt;?php $mysqli = new mysqli("localhost", "root", "", "simple_login"); // TODO - Check that connection was successful. $photo= "images/" . $_FILES["file"]["name"]; $stmt = $mysqli-&gt;prepare("INSERT INTO photo (photo) VALUES (?)"); // TODO check that $stmt creation succeeded // "s" means the database expects a string $stmt-&gt;bind_param("s", $photo); $stmt-&gt;execute(); $stmt-&gt;close(); $mysqli-&gt;close( ?&gt; </code></pre> <p>here is what I tried to display image ...this only shows the file name with path.....</p> <pre><code>&lt;?php $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("simple_login", $con); $result = mysql_query("SELECT * FROM photo"); while($row = mysql_fetch_array($result)) { echo $row['photo']; echo "&lt;br /&gt;"; } mysql_close($con); ?&gt; </code></pre>
php
[2]
3,066,510
3,066,511
Appears nextUntil argument is ignored
<p>In the code below I expect to see the Red, Blue, Green and Brown rows displayed, but it appears all rows, except Red, are hidden as if the nextUntil argument is ignored. Any clues? Thanks.</p> <p>After some research,I tried both </p> <pre><code>$("#firstrow").nextUntil('span[class="hues"]').hide(); </code></pre> <p>and</p> <pre><code>$("#firstrow").nextUntil('span:not(.colors)').hide(); </code></pre> <p>The HTML:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"/&gt; &lt;script&gt; $(document).ready(function() { $("#firstrow").nextUntil('span[class="hues"]').hide(); //$("#firstrow").nextUntil('span:not(.colors)').hide(); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;table id="colortable"&gt; &lt;tr id="firstrow"&gt; &lt;span class="colors"&gt;Red&lt;/span&gt; &lt;/tr&gt; &lt;tr&gt; &lt;span class="colors"&gt;Orange&lt;/span&gt; &lt;/tr&gt; &lt;tr&gt; &lt;span class="hues"&gt;Blue&lt;/span&gt; &lt;/tr&gt; &lt;tr&gt; &lt;span class="shades"&gt;Green&lt;/span&gt; &lt;/tr&gt; &lt;tr&gt; &lt;span class="colors"&gt;Brown&lt;/span&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
jquery
[5]
1,345,051
1,345,052
How to move an element from one place to another in the DOM using plain JavaScript?
<p>I know how to do it in jQUery (untested but should work):</p> <pre><code>$('#foo').html().appendTo('#bar'); $('#foo').remove(); </code></pre> <p>But how to do this in plain JS?</p>
javascript
[3]
3,011,116
3,011,117
JavaScript alternatives
<p>In some projects that I work, was added some blocks with this syntax:</p> <pre><code>var [code, name] = input.split("/"); console.log(code); console.log(name); </code></pre> <p>I really like this, is so simple and small. It's true I can do this using other syntax like:</p> <pre><code>var code_name = input.split("/"); console.log(code_name[0]); console.log(code_name[1]); </code></pre> <p>But, some browsers like Google Chrome and Opera dont support this "feature". Somebody know if this is a future feature of JS or is deprecated? In case deprecated, exist some beaultiful alternative to the first case?</p> <p>Thanks for all.</p>
javascript
[3]
1,721,503
1,721,504
To pass values in a table as an array to javascript
<p>Is there a way that I could pass 5 values of a field from a table as an array to javascript function on onchange event of a dropdown box.</p> <p>The 5 values have to be fetched through sql query.</p>
javascript
[3]
1,442,205
1,442,206
What does this Java construct mean - OneClass object = ( OneClass ) anotherObject;
<p>Sorry for the horrendous question, don't know how else to describe it,</p> <p>I'm naturally a PHPer and i'm currently looking over some java and come across this section. The first line is just there for context, it is the line starting with QuotaKey that I'm interested in.</p> <pre><code>Key key = Keys.getKeyInstance( Keys.getKeyClass( cond.getKey( ) ) ); QuotaKey quotaKey = ( QuotaKey ) key; </code></pre>
java
[1]
2,098,353
2,098,354
What's the easiest way to iterate on a file's lines, keeping a counter?
<p>What's the cleanest code that iterates on the lines of a text file, while simultaniously increamenting a counter?</p> <p>I understand that with multiple assignment, there's a cleaner syntax than</p> <pre><code>i = 0 for line in f: ... ++i </code></pre>
python
[7]
2,474,922
2,474,923
Can I access missed calls from my iPhone app
<p>I want to access the log of missed calls in my iPhone app. How can I do this?</p>
iphone
[8]
5,658,565
5,658,566
Ways to add radio button dynamically using jquery in html
<p>Can anyone suggest me several ways of adding radio buttons with dynamic attributes using jquery....</p>
jquery
[5]
3,728,796
3,728,797
python - how can I display a image from web?
<p>I'm using Python to make a "web album viewer", but I meet some problem.</p> <p>I use Tkinter to write GUI, urllib2 to fetch the image from web, PIL to handle the image</p> <p>So the code is like this:</p> <pre><code>root = Tk() frame = Frame(root) frame.pack() response = urllib2.urlopen(a_pic_url) photo = ImageTk.PhotoImage(Image.open(response.read())) label = Label(frame, image = photo) label.pack() </code></pre> <p>it fails, and throws the following error message:</p> <pre><code>TypeError: file() argument 1 must be (encoded string without NULL bytes), not str </code></pre> <p>How can I overcome this?</p> <p>Thanks, and I'm sorry for my poor English.</p>
python
[7]
5,647,635
5,647,636
Android: change color of row of list
<p>I am working in android.</p> <p>I have a list of place. I want that whenever i click on a place from this list. Then color of that selected row should be changed to BLUE for a short time so it seems to be clicked.</p> <p>this is the code which i trying:-</p> <pre><code> mListView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long duration) { view.setBackgroundResource(R.drawable.fsq_custom_background); } } </code></pre> <p>This is <strong>fsq_custom_background.xml</strong> which is stored in drawable folder:-</p> <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;selector xmlns:android="http://schemas.android.com/apk/res/android"&gt; &lt;item android:state_pressed="true" android:state_enabled="true" android:drawable="@drawable/the_background_color" /&gt; &lt;/selector&gt; </code></pre> <p>this is <strong>the_background_color.xml</strong>:-</p> <pre><code> &lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;shape xmlns:android="http://schemas.android.com/apk/res/android"&gt; &lt;solid android:color="#FF1212" /&gt; &lt;/shape&gt; </code></pre> <p>but still color of selected row is not changed. please help me what mistake i have done. Thank you so much.</p>
android
[4]
5,264,828
5,264,829
Progress bar and percents
<p>I have a progress bar with Minimum=0 and Maximum=1000. Now I have long FileSize=1454545454 and long BytesSent (example). How to calculate progress bar position? I always lose precision or something :/</p> <p>Edit: Solved... I forgot to cast like: (decimal) BytesSent. You guys did same:P Thx for answers. Debbuger always helps.</p>
c#
[0]
5,874,506
5,874,507
Confused by Javascript's variable scope
<p>I'm finding myself by Javascript's variable scope, could someone explain to me why the first example doesn't work but the second does?</p> <pre><code>function test() { return typeof(the_variable) !== 'undefined' &amp;&amp; the_variable; } (function () { var the_variable = "doesn't work"; console.log(test()); }()); var the_variable = "does work"; console.log(test()); </code></pre> <p>Output I get in my log:</p> <pre><code>false does work </code></pre> <p>Also I would like to know how to do something similar to the first example,</p> <p>Cheers, Dave.</p>
javascript
[3]
2,883,387
2,883,388
How to turn element into jQuery selector?
<p>How to turn the event.currentTarget into jQuery object or something like that so I could then use jQuery's addClass method on the object? I know I could just do like: event.currentTarget.className += ' .class', but I was wondering how to work with the event target with jQuery.</p> <pre><code>$('.class').click(function(event) { Class.down($(this).parent().prev().attr('alt')); Class.style($(event.currentTarget)); }); </code></pre>
jquery
[5]
1,183,939
1,183,940
Can't add LINQ to ASP.NET web page
<p>I've got a simple ASP.NET website, but I can't get it to work. The server is running IIS 7.5 with .NET 4.0 installed, and I've got complete access, and I'm using VS2010 to generate an ASP.NET 4 website. But VS automatically generates code-behind files with <code>using System.Linq;</code> in them. This wouldn't be a problem for me except it doesn't seem to reference Linq by default. I added in the IIS Manager/site/.NET Compilation/Assemblies list the System.Data.Linq assembly, <em>and</em> I added a reference to it in the web config, but it's still complaining that <code>System.Linq</code> does not exist.</p> <p>The website works fine on my home machine where I'm developing it with VS2010 installed.</p> <p>What's the problem?</p>
asp.net
[9]
2,231,511
2,231,512
PHP: Image uploading if fail
<p>I am having an upload image system.</p> <p>You upload a image, then you crop it and press save.</p> <p>If you cancel this procedure at after you uploaded the image, the image will remain on the server.</p> <p>So therefore i tried my idea of making a column in db called "failImage", so when you upload the image, it stores the filename e.g 1111.jpg in the column. </p> <p>So later if you cancel this procedure either by shutting down the website or something else, next time you visit, I made a function that checks if failImage is empty. </p> <p>If it isn't then it deletes (unlink) the value in failImage(which is in this example 1111.jpg) and emptys the failImage column.</p> <p>This works fine. </p> <p>But...if you have two windows of my site, and on the 1)st one you upload a image, and then at the 2nd one you refresh the window(f5) the function i made, that unlink the value in failImage runs, and will then occur an error to the previous window you have open, when you try to crop and save it, as it says no such file or directory, as the second window has removed the image you were working with.</p> <p>I have thought of an solution to this for some time, is there any way I can solve this?</p>
php
[2]
563,492
563,493
tar extraction in iphone SDK?
<p>how can i extract tar file in iphone Sdk?i tried both miniZip and libZ.dylib, it extracts only .gZ file. i decompressed <strong>my.tar.gZ</strong> file into <strong>my.tar</strong>.but how can i extract again tar file?any one can help? </p>
iphone
[8]
2,464,757
2,464,758
sort a dict type variable by value in python
<p>I have a dict type variable like <code>{'key1':6,'key2':1,'key3':5,'key4':44}</code> my dictionary contains millions of key:val pair I want to store it in txt file such that key corresponding to highest val comes first and so on in descending order eg my txt file will look like</p> <pre><code>key4: 44 key1: 6 key3: 5 key2: 1 </code></pre>
python
[7]
5,270,751
5,270,752
satisfying app dependency on Google Maps api
<p>I'm developing an app that uses the Google Maps api to give you a list of a given business type at runtime based on your current location.</p> <p>I developed this on Eclipse using my LG Ally running Android 2.2.2 as a test device. </p> <p>The QA team is not local to me so I emailed them the same apk file I installed on my phone. </p> <p>Here's where it gets strange.</p> <p>One tester, was able to install the app and run it with no problems. That person is using a phone running Android 2.2.2 - just like I am, although I am unsure if their phone is an LG Ally.</p> <p>The other person is using a phone running 2.3.3 and they are unable to run the app. They've installed an app that emails me the logcat output and the only message that looks even vaguely related is:</p> <p>06-21 14:22:57.147 W/PackageInstaller( 8784): Parse error when parsing manifest. Discontinuing installation</p> <p>I've read on Stackoverflow that the manifest must contain info about the sdk. My Android Manifest contains: </p> <pre><code>&lt;uses-sdk android:minSdkVersion="7" android:targetSdkVersion="15"/&gt; </code></pre> <p>I've also read on Stackoverflow that some people have problems installing apps emailed to them and suggested something like DropBox.</p> <p>I've done both (included the above sdk line in my Manifest and delivered the app via DropBox) and they are still unable to run the app.</p> <p>Which got me wondering about the Google Maps dependency. I'm not delivering the maps.jar file in my apk. Is there a way I can check that the maps.jar is available on the device where my app is running? Is there a way I can deliver the maps.jar file? What do I do if maps.jar is already present?</p>
android
[4]
4,650,391
4,650,392
Having trouble with a simple jQuery image loader
<p>I am trying to implement a simple script of image thumbnails, that when clicked, display a larger image.</p> <p>I am trying to do this without using an existing plugin.</p> <p>Here is my current code.</p> <pre><code>$('#thumbnails ul li').click(function() { $('#main').attr('src', $(this).attr('src').replace('small/', 'large/'));});​ </code></pre> <p>Can someone please let me know what I am doing wrong? I have also upload the whole code here... <a href="http://jsfiddle.net/PjrFe/" rel="nofollow">http://jsfiddle.net/PjrFe/</a></p> <p>Thanks in advance guys. </p>
jquery
[5]
6,002,503
6,002,504
intellisense cannot open source file " .tlb" in C++
<p>Iam tring to deploy my C# dll in C++, by converting it .tlb. But, while im importing it into C++ program, using the statement</p> <pre><code>#import "MyProject.tlb" named_guids raw_interfaces_only </code></pre> <p>Iam geting the error </p> <pre><code>intellisense cannot open source file " c:/.../debug/MyProject.tlh" bad descriptor for file. </code></pre> <p>Also getting the warning: </p> <pre><code>#import skipped when looking for precompiled header use </code></pre> <p>Can anyone help me in this?</p>
c++
[6]
3,341,900
3,341,901
Dubugging of OrangeHRM
<p>I have source code of OrangeHRM in my machine, but i am not able to debug the code. Could you help me to resolve this problem...</p>
php
[2]
5,690,919
5,690,920
How to get the innnerhtml of a div using jQuery
<p>I want to get the innerhtml of div in Jquery using <code>.html()</code> but it is not displaying anything. whereas id is not null</p>
jquery
[5]
3,579,450
3,579,451
if array undefined
<p>How do I check if an array is undefined? I am using <code>isset</code> and <code>empty</code> but both of them are not working for an undefined array.</p> <p>This is my code:</p> <pre><code>if (isset($content['menu']['main'])){ echo 'there is menu'; } </code></pre>
php
[2]
5,246,227
5,246,228
How to stop unwanted postback
<p>I work on asp.net C# ....Under button click event i want to save something it's work fine ...<strong>.but after press the refresh button of browser</strong> ,this event occurs again i want to stop this event....</p>
asp.net
[9]
2,511,635
2,511,636
Why do we need a function plugin when we write a method plugin
<p>I am a JQuery newbie and I came across this jquery plugin sample code when I was reading a Jquery book.</p> <pre><code>//adding a function to JQuery object jQuery.slowEach = function( array, interval, callback ) { if( ! array.length ) return; var i = 0; next(); function next() { if( callback.call( array[i], i, array[i] ) !== false ) if( ++i &lt; array.length ) setTimeout( next, interval ); } return array; }; //attaching a new method .slowEach() jQuery.fn.slowEach = function( interval, callback ) { return jQuery.slowEach( this, interval, callback ); }; // Show an element every half second $('.reveal').slowEach( 500, function() { $(this).show(); }) </code></pre> <p>I just want to know if it's necessary to write the function plugin when I'm writing such method plugin, and whats the significance? If not, can I write the whole thing in the jQuery.fn.slowEach method without the function plugin?</p> <p>Thanks!</p>
jquery
[5]
1,979,056
1,979,057
How to make on click an label combo box should appear
<p>On click an label an combo box should appear... please check <a href="http://guruji.com/en/local.html" rel="nofollow">http://guruji.com/en/local.html</a> on clicking near mycity the label changes into combobox (dropdown list)..how to do it.</p>
javascript
[3]
5,310,947
5,310,948
Getting multiple check box results in POST with php
<p>Hi i have a form that send across a single check box, which is working perfect, however when i add a second tick box, the second one doesn't seem to pass any information. The first one works but the second one doesn't.</p> <p>Below is my code, any suggestions would be appreciated, thanks.</p> <p>Form Side</p> <pre><code>"&lt;input type='checkbox' name='ip[]' value='$row[ip]'/&gt;"; "&lt;input type='checkbox' name='in[]' value='$row[ip]'/&gt;"; </code></pre> <p>add Side</p> <pre><code>$ip_array = isset($_POST['ip']) &amp;&amp; is_array($_POST['ip']) ? $_POST['ip'] : array(); foreach( $ip_array as $ip ) { $in_array = isset($_POST['in']) &amp;&amp; is_array($_POST['in']) ? $_POST['in'] : array(); foreach( $in_array as $in ) { </code></pre> <p>The top part of the code seems tocatch the checkbox fine but the bottom one doesn't.</p>
php
[2]
2,358,821
2,358,822
Try Except in python :syntax issue
<pre><code>class ShortInputException(Exception): '''A user-defined exception class.''' def __init__(self, length, atleast): Exception.__init__(self) self.length = length self.atleast = atleast try: s = raw_input('Enter something --&gt; ') if len(s) &lt; 3: raise ShortInputException(len(s), 3) except ShortInputException, x: print 'ShortInputException: The input was of length %d, \ was expecting at least %d' % (x.length, x.atleast) </code></pre> <p>I dont understand the syntax of this line: <code>except ShortInputException, x:</code></p> <p>what is x here for ?? and why is it acting as an object ???</p> <p>waht does this line do ? : <code>Exception.__init__(self)</code></p> <p>Thanks</p>
python
[7]
5,888,425
5,888,426
Android memory leak detection using MAT
<p>I am trying to analyze the heap dump of my android app. The analyzer MAT shows me this message</p> <p>The class "android.content.res.Resources", loaded by "", occupies 12,084,776 (87.38%) bytes. The memory is accumulated in one instance of "java.lang.Object[]" loaded by "".</p> <p>What do I do about this? I want to avoid OutOfMemoryError.</p>
android
[4]
2,481,456
2,481,457
Saving List of Strings in Java
<p>am having problem in Saving some data in my Java code. </p> <p>I have like three different methods which do some respective tasks. Am calling these methods using Hessian from Php client. And am not calling this three methods at a time. Each method will create some arrays(contains strings, int, float), and some time i have to use those arrays which was created my previous methods call in this present method. </p> <p>Is there any way i can save that Arrays(not in database), may be a List or Array which will not flush the memory unless i say soo.. </p> <p>Example </p> <pre><code>public class top{ Method1(){ String[] stringA = {some string data} ; } Method2(){ for(string data : stringA){ I use array of stringA from method1 without calling the whole method1. I need that string value to be save untill i flush it out. } } } </code></pre> <p>This is not a complete code.. not even a code. Am just trying to explain the issue.</p> <p>Any help please.</p> <p>Thanks.</p>
java
[1]
5,136,125
5,136,126
unable to create MIDlet with j2me
<p>i use WTK 2.5.2 . I am getting an error while running my program . the nature of error is .. </p> <pre><code>Unable to create MIDlet HelloMidlet java.lang.ClassNotFoundException: HelloMidlet at com.sun.midp.midlet.MIDletState.createMIDlet(+29) at com.sun.midp.midlet.Selector.run(+22) </code></pre> <p>.. what would be the reason .. please suggest .</p>
java
[1]
1,230,305
1,230,306
php array last index
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/2348205/how-to-get-last-key-in-an-array">How to get last key in an array?</a> </p> </blockquote> <p>I have an array</p> <pre><code>$arr=Array ( [0] = Array ( [groupid] = 1 [groupname] = Oxy [members] = Array ( [0] = Array ( [id] = 9 [name] =&amp;gt; Anith ) [1] = Array ( [id] = 12 [name] = sanjay ) [3] =Array ( [id] = 13 [name] = Sooraj K ) ) ) ) </code></pre> <p>Here <code>$arr[0]['members'][2]</code> is unsetted. I want to find the last index of <code>$arr[0]['members']</code> here that is 3..how can i find this last index</p>
php
[2]
2,441,740
2,441,741
How can I place an background image to a the left upper corner of TextView in android
<p>Can you please tell me how can I place an background image to a the left upper corner of TextView in android? I would like the image not to be scaled by android.</p> <p>I have tried </p> <p>Resources res = getResources(); setCompoundDrawables(res.getDrawable(R.drawable.icon48x48_1), null, null, null);</p> <p>Nothing is shown.</p> <p>And I have tried setBackground(R.drawable.icon48x48_1); </p> <p>But it stretches the image.</p> <p>Thank you for any help.</p>
android
[4]
3,993,267
3,993,268
How to get the relative path name?
<p>I am wondering how to get the relative path name? Any existing library can help this?</p> <p>c:\123 c:\123\1234\zaq\erf</p> <p>I would like to get something like 123/1234/zaq/erf</p>
java
[1]
2,329,074
2,329,075
Cancel DoWork in BackgroundWorker C#
<p>I'm working with an application using BackgroundWorker. I wanted to add Cancel functionality. However, I don't know how to implement cancellation of DoWork tasks. Are there any sample that may help me? Thanks in advance. :)</p>
c#
[0]
4,715,797
4,715,798
How to disable the page extension in browser[url]?
<p>In asp.net, how can we disable the page extension in the browser. can you help me. Thank you.</p>
asp.net
[9]
2,413,259
2,413,260
What is operator ~ for?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/7261652/javascript-bitwise-operator-question">javascript bitwise operator question</a> </p> </blockquote> <p>Documentation says, that it is <code>bitwise NOT</code>. But I don't understand these examples:</p> <pre><code>var a = ~1; a -2 var a = ~8; a -9 var a = ~-1; a 0 </code></pre>
javascript
[3]
3,659,009
3,659,010
Modifying Date Slider for android
<p>I am trying to modify <a href="https://code.google.com/p/android-dateslider/" rel="nofollow">Dateslider for Android</a> to be only a time slider.</p> <p>I have reduced it to </p> <p><img src="http://i.stack.imgur.com/eufYL.png" alt="enter image description here"></p> <p>What I want is when time is "17:00" 17 should be in the middle instead of a bit to right. </p> <p>Basically what I want is to put a pointer at the time selected. It would be easier to put it in middle like this </p> <p><img src="http://i.stack.imgur.com/7ORMx.png" alt="enter image description here"></p> <p>So my question goes to someone who has already used this lib. understands it a bit better than me and can help me out here. </p> <p>PS: I believe it has got to something with <code>ScrollLayout.java</code></p>
android
[4]
2,493,902
2,493,903
Python: Importing a file from a parent folder
<p>...Now I know this question has been asked many times &amp; I have looked at these other threads. Nothing so far has worked, from using sys.path.append('.') to just import foo</p> <p>I have a python file that wishes to import a file (that is in its parent directory). Can you help me figure out how my child file can successfully import its a file in its parent directory. I am using python 2.7</p> <p>The structure is like so (each directory also has the <strong>__<em>init</em>__</strong>.py file in it):</p> <blockquote> <p>StockTracker/<br> <strong>__</strong><em>Comp/<br> <strong></em>____</strong><em>a.py<br> <strong></em>____</strong><em>SubComp/<br> <strong></em>__<em>_</em>__</strong>_b.py</p> </blockquote> <p>Inside b.py, I would like to import a.py: So I have tried each of the following but I still get an error inside b.py saying "There is no such module a" </p> <pre><code>import a import .a import Comp.a import StockTracker.Comp.a import os import sys sys.path.append('.') import a sys.path.remove('.') </code></pre>
python
[7]
1,321,224
1,321,225
validation function problem
<p>Hello I am not able to get the correct validation.I think there is some error in this code so can anyone please help me solving this problem.</p> <pre><code> public static boolean validateFee(String value) { boolean isvalid = true; try { int fee = 0; if (value != null &amp;&amp; !value.isEmpty()) { fee = Integer.parseInt(value); } } catch (NumberFormatException ne) { // ne.printStackTrace(); isvalid = false; return isvalid; } return isvalid; } } </code></pre> <p>I am actaully using this code for validation of fee in which i m using a regex as [0-9]+. This code i m using it in a common function.Actually validation call is done in the servlet as follows:</p> <pre><code>private Boolean validateFee(HttpSession session, PropertiesHandler props, String number) { Boolean isvalid = true; HashMap hashMap = new LinkedHashMap(); number = ApplicationConstants.FEE_PATTERN; if (!Validation.validateFee(number)) { isvalid = false; hashMap.put("time", props.getText("error.fee.invalid.type")); } session.setAttribute("errorMessage", hashMap); System.out.println("Map size " + hashMap.size()); logger.info("Exit validateTIme"); return isvalid; } </code></pre> <p>I think there is no error in that but i have a doubt in this function.I am facing a problem like if i give number to the fee also its taking validation.please help me out</p>
java
[1]
3,112,959
3,112,960
how to get fist class name from class like class="class1 abc" get 'class1'
<p>i have li that has class name more then one ,</p> <p>so i want to get first class name </p> <pre><code> For Example &lt;li class="class1 smfont"&gt;1&lt;li&gt; &lt;li class="class2 smfont"&gt;2&lt;li&gt; &lt;li class="class3 smfont"&gt;3&lt;li&gt; &lt;li class="class5 smfont"&gt;5&lt;li&gt; </code></pre> <p>i want to get the class name only class1, class2, class3.... by jquery</p> <p>i use</p> <pre><code>var $filteredData = $data.find('li[class=' + $filterType + ']'); </code></pre> <p>but not work</p>
jquery
[5]
407,138
407,139
UITableView paging Load More from the server iPhone
<p>I am looking to load results from the server for UITableView while I have that implemented, I want to enable paging for those results.</p> <p>Does anyone know any article that will explain me this or can someone explain here?</p> <p>Thanks</p>
iphone
[8]
476,387
476,388
Sorting an IList
<p>I have got a complete list of my brands to appear in my <code>DropDownBox</code>, however there appears to be no order (simply how they are input into the database) and I need to sort them into alphabetical order.</p> <p>But it doesn't look like I can use the .Sort(); on an <code>IList</code> and there doesn't seem to be anything similar on <code>ILists</code> so I am at a bit of a loss, I have tried to convert the <code>IList</code> into a <code>List</code> and then using the <code>List.Sort()</code> method but I have had no luck with this as it just comes back unsorted again:</p> <pre><code>public void BrandListRetrieve() { var factory = new BrandFactory(); var customBool1State = factory.ByCustomBoolean1(false, CoreHttpModule.Session); if (customBool1State != null) { var brandDropDown = CoreHttpModule .Session .CreateCriteria(typeof(Brand)).List&lt;Brand&gt;(); foreach (Brand brand in brandDropDown) { this.Items.Add(brand.Name); } if (this.Items.Count &lt; 0) { this.Items.Insert(0, new ListItem("Hello World", "Hello World")); } var brandList = brandDropDown as List&lt;string&gt;; if (brandList != null) brandList.Sort(); } } </code></pre>
c#
[0]
1,683,273
1,683,274
M2CRYPTO generating RSA key pair with automotically passphrase
<p>I am using this "key = RSA.gen_key(2048, 65537,genPass)" for RSA key generation, It is asking to enter a passphrase. How can i generate it without passphrase from user?and put some known passphrase automaticlly? Thanks.</p>
python
[7]
4,116,648
4,116,649
Python: Deleting files of a certain age
<p>So at the moment I'm trying to delete files listed in the directory that are 1 minute old, I will change that value once I have the script working.<br> The code below returns the error: <code>AttributeError: 'str' object has no attribute 'mtime'</code></p> <pre><code>import time import os #from path import path seven_days_ago = time.time() - 60 folder = '/home/rv/Desktop/test' for somefile in os.listdir(folder): if int(somefile.mtime) &lt; seven_days_ago: somefile.remove() </code></pre>
python
[7]
2,704,644
2,704,645
Non-lvalues as function parameters in C++
<p>I'm reading Accelerated C++ and in Chapter 4 they bring up the concept of lvalues. There's an example of something that <em>shouldn't</em> work, but after trying it myself I found that it does indeed work.</p> <p>Specifically they state that, given these functions:</p> <pre><code>// return an empty vector vector&lt;double&gt; emptyvec() { vector&lt;double&gt; v; return v; } // read things from an input stream into a vector&lt;double&gt; // (I'm leaving out the function body here because it's irrelevant) istream &amp;read_things(istream&amp; in, vector&lt;double&gt;&amp; hw); </code></pre> <p>This should not be allowed:</p> <pre><code>read_stuff( cin, emptyvec() ); </code></pre> <p>Because emptyvec() is an expression and returns a temporary object (a <em>non-lvalue</em> as they called it in the book). However, this not only compiles but actually runs (Windows 7/VisualStudio 2010).</p> <p>So, what's going on? Was this just a bad example on the authors' part, or is there something else happening that I don't understand.</p> <p>Thanks.</p>
c++
[6]
1,685,350
1,685,351
Android programming to bring contacts
<p>Hello Experts am new to the Android world, I want to know the code of how to bring phone contacts in an app on pressing a button with checkboxes to select some contacts.</p> <p>Please help me. </p> <p>Thank you,</p> <p>Mehboob</p>
android
[4]
604,132
604,133
find most occurence element in array
<p>Here is simple program to find the element which occurs most often in an array:</p> <pre><code>#include &lt;cstdlib&gt; #include &lt;iostream&gt; #include &lt;vector&gt; using namespace std; int main(int argc, char *argv[]) { int a[] = {1,2,3,4,4,4,5}; int n = sizeof(a) / sizeof(int); int max = 0; int result = 0; int *b = new int[n]; for (int i = 0; i &lt; n; i++) { b[a[i]] = (b[a[i]] || 0) + 1; if (b[a[i]] &gt; max) { max = b[a[i]]; result = a[i]; } } cout &lt;&lt; result &lt;&lt; endl; system("PAUSE"); return EXIT_SUCCESS; } </code></pre> <p>But it doesn't work; it prints <code>1</code>. Why?</p>
c++
[6]
1,489,929
1,489,930
how to compare keyboard input to a string in Python?
<p>I m trying to compare keyboard input to a string:</p> <pre><code>import sys # read from keyboard line = sys.stdin.readline() if line == "stop": print 'stop detected' else: print 'no stop detected' </code></pre> <p>When I type 'stop' at the keyboard and enter, I want the program to print 'stop detected' but it always prints 'no stop detected'. How can I fix this?</p>
python
[7]
2,477,582
2,477,583
Controlls are not displaying in interface builder?
<p>i am facing a problem with IBOutlet,please Respected developers help me out, as i am fresher in iphone</p> <p>for eg. i declared buttons or controls with IBOutlet in .h file ,but many times interface builder is not showing the controls so i use to exit the application and reopen it again and i found it so is there any thing i am missing. </p> <p>thanks in advance...</p>
iphone
[8]
5,907,670
5,907,671
Cannot create handle for image after obtaining source code
<p>I am trying to create a small experimental script for obtaining comic strips from web-comic sites using php. The site that I am playing with is <a href="http://www.pidjin.net/" rel="nofollow">Fredo and Pidjin</a>. Here is the code that I have written so far: </p> <pre><code>&lt;?php require_once "../shdp/simple_html_dom.php"; $next = "http://www.pidjin.net/2012/08/28/of-my-own/"; $html = file_get_html($next); $imageList = $html-&gt;find('div[class=episode] p img'); for($iii=0; $iii&lt;count($imageList); $iii++){ $storage[$iii] = $imageList[$iii]-&gt;src; } $img = file_get_contents($storage[0]); $img = imagecreatefromstring($img); header("Content-type: image/png"); $something = imagepng($img); ?&gt; </code></pre> <p>For scraping the html, I am using the Simple HTML DOM parser. </p> <p><strong>This is what I'm trying to do:</strong> Get the src of the image and assign it to a handle. Subsequently find it for all the comic panels on the page and use imagecopy to make one strip that can be saved to the computer. The code, however, is in the preliminary stages and I have not got to the imagecopy part yet.</p> <p><strong>Problem</strong>: While imagepng(...) outputs the file on the browser, I am not able to get a $src handle (so to speak) on the image to use in imagecopy.</p> <p>Thanks in advance.</p>
php
[2]
5,917,235
5,917,236
What is the pythonic way to remove trailing spaces from a string?
<p>The parameter to the function satisfy these rules:</p> <ol> <li>It does not have any leading whitespace</li> <li>It might have trailing whitespaces</li> <li>There might be interleaved whitespaces in the string.</li> </ol> <p>Goal: remove duplicate whitespaces that are interleaved &amp; strip trailing whitespaces.</p> <p>This is how I am doing it now:</p> <pre><code># toks - a priori no leading space def squeeze(toks): import re p = re.compile(r'\W+') a = p.split( toks ) for i in range(0, len(a)): if len(a[i]) == 0: del a[i] return ' '.join(a) &gt;&gt;&gt; toks( ' Mary Decker is hot ' ) Mary Decker is hot </code></pre> <p>Can this be improved ? Pythonic enough ?</p>
python
[7]
5,756,774
5,756,775
How to send parameters when need to call http post call ?
<p>I need to use some service. The service method that i need to call need to get two parameters 1. int 2. some enum </p> <p>I don't know how to send those parameters and how to make this call. I wanted to use this code </p> <pre><code>List&lt;NameValuePair&gt; nameValuePairs = new ArrayList&lt;NameValuePair&gt;(2); nameValuePairs.add(new BasicNameValuePair("param1", val1); nameValuePairs.add(new BasicNameValuePair("param2", val2); httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); HttpResponse p = httpclient.execute(httppost); </code></pre> <p>But this code can't send int as parameter ( only string ) The second parameter ( that is some enum ) i think that i can send as string and the service in the other side will translate this string to enum ( am i right ? ) </p>
android
[4]
3,346,788
3,346,789
Javascript: generate random nice saturated colors (selected palette)
<p>i saw a lot of Js example but none fit my needs:</p> <p>I'd like to have a script to generate colros, but if I use the common solution</p> <pre><code>color = '#'+Math.floor(Math.random()*16777215).toString(16); </code></pre> <p>it generates pastel colors, where I'd like better more saturated colors...or more ambitious, how can i select the palette form which i pick the colors?</p> <p>how can I "restrict" the randomness?</p>
javascript
[3]
2,205,141
2,205,142
Base64Encoder cannot be resolved
<p>This is my Java code in a JSP file. I am getting </p> <blockquote> <p>Base64Encoder cannot be resolved. </p> </blockquote> <p>Why is it so? I have to add something related to <code>Base64Encoder</code>. Any suggestions will be appreciated.</p> <pre><code> &lt;%@ page language="java" import="java.io.OutputStream,java.net.HttpURLConnection,java.net.URL,java.util.Collection,org.apache.commons.httpclient.Credentials,org.apache.commons.httpclient.auth.AuthenticationException,org.apache.commons.httpclient.auth.MalformedChallengeException,org.apache.commons.httpclient.params.DefaultHttpParams,org.apache.commons.httpclient.params.HttpParams,org.apache.commons.httpclient.auth.AuthScheme,org.apache.commons.httpclient.auth.AuthPolicy,org.apache.commons.httpclient.HttpClient,org.apache.commons.httpclient.UsernamePasswordCredentials,org.apache.commons.httpclient.auth.AuthScope,org.apache.commons.httpclient.methods.GetMethod,org.w3c.dom.*,javax.xml.parsers.DocumentBuilder,javax.xml.parsers.DocumentBuilderFactory,java.net.*,java.io.*" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%&gt; &lt;% String a_Url = request.getParameter( "url" ) ; URL url = new URL (a_Url); String encoding = Base64Encoder.encode ("test:test"); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod("GET"); connection.setDoOutput(true); connection.setRequestProperty ("Authorization", "Basic " + encoding); InputStream content = (InputStream)connection.getInputStream(); BufferedReader in = new BufferedReader (new InputStreamReader (content)); String line; while ((line = in.readLine()) != null) { System.out.println(line); } %&gt; </code></pre>
java
[1]
584,260
584,261
How to open image closeup view, on onclick of image in iphone?
<p>I have one image view, I set the image on it. I want to open closeup view of that image by onclick of that image. How we can achieve this? any idea</p>
iphone
[8]
5,913,141
5,913,142
(JAVA)Terminate function on System.in .. possible?
<p>I am currently working on a project in JAVA where I have to make an agent to interact with a server.</p> <p>Each 50ms, the server will receive the last thing I outputted to System.out and send me a new set of lines as a 'state' through the System.in printstream to analyze and send my next message to System.out.</p> <p>Also, if the server receives multiple outputs from me, it only regards the most recent one.</p> <p>..</p> <p>As for my question:</p> <p>My program originally constructed a tree and then analyzed each leaf node to see which would be optimal, and then waited around for the next input, but I can recursively do a deeper tree search that would make my output 'better' (and again and again to keep returning a better result).</p> <p>Using this and the fact that if the server receives multiple outputs, it only takes the most recent one, I could do each level, print my result and start the next level. But here comes my problem...</p> <p>I can't be stuck in some complex algorithm while I am supposed to receiving the next input as I will then miss it. So I was wondering if there is a way to cancel anything else I am doing when I receive something via System.in and then go back to the beginning of the function and start the search again with the new set of input (and rinse and repeat..)</p> <p>I hope this all makes sense,</p> <p>Thank ye all</p>
java
[1]
231,660
231,661
how to copy a file between 2 computers on the network in python
<p>I am trying to move a log file from a computer, where an operation is performed, to another computer, that will get the log file and process it, returning a document with the result of the analysis.</p> <p>I am using Python for the job, but I am open to other options (I have to run this copy via console on OSX, due the fact that most of my work is done in shell scripting; so cannot use any visual solution; anything that can be launched via a script would work too); any suggestion is more than welcome since I do not really have a favorite way to do this (just trying the less problematic....I do not need any security encryption since both of the computers are on my internal network, no communication with the outside is performed).</p> <p>Hope that someone can point me to the right solution, thanks in advance.</p>
python
[7]
2,400,369
2,400,370
#define mockable virtual in C++
<p>I found this code:</p> <p><code>#define mockable virtual</code></p> <p>Do you have any idea why somebody will define virtual like this? I'm just curios what's the point of doing this</p>
c++
[6]
356,491
356,492
How can I restart a BaseHTTPServer instance?
<p>This is what I have:</p> <p>http.py:</p> <pre><code>class HTTPServer(): def __init__(self, port): self.port = port self.thread = None self.run = True def serve(self): self.thread = threading.Thread(target=self._serve) self.thread.start() def _serve(self): serverAddress = ("", self.port) self.server = MyBaseHTTPServer(serverAddress,MyRequestHandler) logging.log(logging.INFO, "HTTP server started on port %s"%self.port) while self.run: self.server.handle_request() def stop(self): self.run = False self.server.server_close() </code></pre> <p>Then in another file, to restart it:</p> <pre><code>def restartHTTP(self): try: self.httpserver.stop() reload(http) self.httpserver = http.HTTPServer(80) self.httpserver.serve() except: traceback.print_exc() </code></pre> <p>This gives me an address already in use error, so it seems the HTTP server isn't stopping properly. What else do I need to do to stop it?</p> <p>EDIT: </p> <p>Where I call restartHTTP:</p> <pre><code>def commandHTTPReload(self, parts, byuser, overriderank): self.client.factory.restartHTTP() self.client.sendServerMessage("HTTP server reloaded.") </code></pre> <p>I do know the command is executing because I get the message it's supposed to send.</p>
python
[7]
4,583,499
4,583,500
I have a redirect error
<p>I'm working on a simple login form and i have this redirect URL:</p> <pre class="lang-html prettyprint-override"><code>&lt;form method="post" action="/incs/login.php?redirect=&lt;?php echo $_SERVER['PHP_SELF'];?&gt;"&gt; </code></pre> <p>but when I'm filling the form and hit the submit button I'm redirected to a wrong URL:</p> <pre class="lang-none prettyprint-override"><code>http://site/incs/login.php?redirect=/admin/index.php </code></pre> <p>which it's supposed to be like this:</p> <pre class="lang-none prettyprint-override"><code>http://site/admin/index.php </code></pre> <p>I'm following an old guide and I have looked for this (redirect) function on the internet but I could not find anything. Does this still work now or is it not supported any more?</p>
php
[2]
5,967,660
5,967,661
JQuery How to extract value from href tag?
<p>I am new to JQuery.</p> <p>If I have the following tag. What is the best JQuery method to extract the value for "page" from the href.</p> <pre><code>&lt;a href="Search/Advanced?page=2"&gt;2&lt;/a&gt; </code></pre> <p>Malcolm</p>
jquery
[5]
4,522,100
4,522,101
Faster version of Convert.ChangeType
<p>In an application that I have, I am doing quite frequent calls to <code>Convert.ChangeType</code> in order to convert a value to a dynamically loaded type. </p> <p>However, after profiling with ANTS, I've found that this <code>Convert.ChangeType</code> seems to take a significant portion of time (due to being called quite often). Does anyone have a faster alternative to doing this?</p> <p>At this point I have a type object containing the target, and a <code>string</code> containing the value.</p> <p>The following is the offending code. I was considering doing a switch-statement on type (since it is a limited collection of types) and calling the parse methods, though I'm not sure whether or not that'll be faster.</p> <pre><code>if(attributeRow["Value"]!=DBNull.Value) sample[attr] = attr.AttributeType == typeof(Guid) ? new Guid(attributeRow["Value"].ToString()) : (IComparable)Convert.ChangeType(attributeRow["Value"],attr.AttributeType); </code></pre>
c#
[0]
2,236,374
2,236,375
__getattr__ doesn't work with __enter__ -> AttributeError
<p>I would like to use <code>with</code> on an object that uses <code>__getattr__</code> to redirect calls.<br> Howerver, this does not seem to work with the method <code>__enter__</code></p> <p>Please consider the following, simplified code to reproduce the error:</p> <pre><code>class EnterTest(object): def myenter(self): pass def __exit__(self, type, value, traceback): pass def __getattr__(self, name): if name == '__enter__': return self.myenter enter_obj = EnterTest() print getattr(enter_obj, '__enter__') with enter_obj: pass </code></pre> <p>Output:</p> <pre><code>&lt;bound method EnterTest.myenter of &lt;__main__.EnterTest object at 0x00000000021432E8&gt;&gt; Traceback (most recent call last): File "test.py", line 14, in &lt;module&gt; with enter_obj: AttributeError: __enter__ </code></pre> <p>Why doesn't it fall back to <code>__getattr__</code> since <code>__enter__</code> does not exist on the object?</p> <p>Of course, I could make it work if I just create an <code>__enter__</code> method and redirect from there instead, but I'm wondering why it doesn't work otherwise.</p> <p>My python version is the following:</p> <pre><code>C:\Python27\python27.exe 2.7 (r27:82525, Jul 4 2010, 07:43:08) [MSC v.1500 64 bit (AMD64)] </code></pre>
python
[7]
2,674,553
2,674,554
How to Include JavaScript on a Public Facing Website?
<p>I am building a public facing website and I am using a lot of jQuery and jQueryUI. What I have noticed is that most site on internet that use jQuery and jQueryUI don't have code like this in their pages.</p> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function(){ $("a").click(function(event){ alert("Thanks for visiting!"); }); $( "input:submit" ).button(); }); &lt;/script&gt; </code></pre> <p>I know this is a simplistic example but most sites, for example SO have only one obfuscated js file included for all the pages. It doesn't even seem like they use $(document).ready anywhere. On my current site it seems like I would need to include a js file for each page. My question is how is it suppose to be done and is there a best practice on how to use/include javascript in a page?</p>
javascript
[3]
2,727,798
2,727,799
Jquery "Open url after function completet"
<p>Hello I'm working on this page where i wan't to open a url after the animation is completet.</p> <p>I have this but it dosen't seem to work. I'm tottaly new in Jquery.</p> <pre><code>$('h1').click(function() { $(this).parent().animate({ "width" : "100%", "height" : "900px" }, function() { $(this).load('index2.html'); }); </code></pre>
jquery
[5]
913,643
913,644
Reason why window.print() javascript doesnt get previewed in chrome
<p>I have a link in a page which I am using for print the page using window.print(), I want reason why this is not showing preview in Chrome until unless I Add return false in after window.print().</p>
javascript
[3]
5,696,969
5,696,970
jQuery selecting row inserted using
<p>I'm successfully inserting a row into my table via</p> <pre><code>$('#fbs tr:last').after('&lt;tr&gt;&lt;td&gt;&lt;input id="vm" type="checkbox" /&gt;&lt;/td&gt;&lt;/tr&gt;'); </code></pre> <p>However after that I'm trying to select $('#vm') and not receiving anything. Everything looks right but jQuery isn't finding the element.</p>
jquery
[5]
1,895,442
1,895,443
Python: reading '\xc2' from file prints fine but printing string variable with same value fails
<pre><code> with open(path) as f: for line in f: print line </code></pre> <p><code>path</code> is file with single line as <code>\xc2</code></p> <p>when I run this I get </p> <p><code>\xc2</code></p> <p>now lets change this</p> <pre><code>with open(path) as f: for line in f: var = '\xc2' print var </code></pre> <p>When I run this, I see </p> <pre><code>UnicodeDecodeError: 'ascii', '\xc2d', 0, 1, 'ordinal not in range(128)' </code></pre> <p>then I try to compare the so I do</p> <pre><code>with open(path) as f: for line in f: line = line.strip() line1 = '\xc2d' # print line1 print line == line1 </code></pre> <p>and I see <code>False</code></p> <p>What is happening here??</p>
python
[7]
3,183,939
3,183,940
My program fills memory. Is there another approach?
<p>I know that the object refguess becomes 95^n characters long and that's what's being stored in the memory. Is it possible to load and iterate one element into memory at a time, erasing it before loading a new element? Eventually, I want to port this to run on a GPU to take advantage of the shader cores' superior number crunching ability, so a small RAM footprint would be optimal.</p> <pre><code>import itertools import string i = 1 refguess = '' password = ' ~}}' charlist = list(string.printable) charlist = charlist[1:95] while refguess != password: i += 1 for idx, val in enumerate(list(itertools.product(charlist,repeat=i))): refguess = ''.join(map(str,val)) if refguess == password: print('Password is ' + '(' + refguess + ')') break </code></pre>
python
[7]
2,440,651
2,440,652
Having issues when trying to insert an ajax response which is an html block into an element on IE 8 using innerHTML
<p>Hello Everyone just like my title states, I am having issues with IE8 and innerHTML. For whatever reason, when I make an ajax call which returns an html block and try to insert it into an element using innerHTML, the browser gives me an error "Unknown Error Code: 0".</p> <p>The interesting part of this is that, if the message response does not have html element, innerHTML works. My code is like so:</p> <pre><code>setTimeout(function() { element.innerHTML = context.response.message; }, 1000).bind(context) </code></pre> <p>WORKS:</p> <pre><code>context.response.message = 'String'; </code></pre> <p>Does not WORK:</p> <pre><code>context.response.message = '&lt;p&gt;String&lt;/p&gt;'; </code></pre>
javascript
[3]
4,702,818
4,702,819
How do I get the rendered web page page from a URL?
<p>I don't want just the source code. I want the rendered page. This is an important distinction that I apparently cannot make by simply searching Google.</p> <p>Does anyone know how I can get the <strong>rendered</strong> page from a URL?</p> <p>This needs to be done in Java, hopefully without an extra library.</p>
java
[1]
1,456,356
1,456,357
Anonymous functions usage
<p>Just wondering what the preferred method of using anonymous functions is.</p> <p>First I had some code like this:</p> <pre><code>function page_columns( $columns ) { $columns = array( 'cb' =&gt; '&lt;input type="checkbox" /&gt;', 'title' =&gt; 'Title', 'author' =&gt; 'Author', 'template' =&gt; 'Template', 'date' =&gt; 'Date' ); return $columns; } add_filter('manage_edit-page_columns', 'page_columns'); </code></pre> <p>But I know WordPress discourages using variables for things that will only be used once so I switched it to</p> <pre><code>function page_columns( $columns ) { return array( 'cb' =&gt; '&lt;input type="checkbox" /&gt;', 'title' =&gt; 'Title', 'author' =&gt; 'Author', 'template' =&gt; 'Template', 'date' =&gt; 'Date' ); } add_filter('manage_edit-page_columns', 'page_columns'); </code></pre> <p>But now I'm thinking why even use a function at all?</p> <pre><code>add_filter('manage_edit-page_columns', function(){ return array( 'cb' =&gt; '&lt;input type="checkbox" /&gt;', 'title' =&gt; 'Title', 'author' =&gt; 'Author', 'template' =&gt; 'Template', 'date' =&gt; 'Date' ); }); </code></pre> <p>What is the preferred method? Any reason why? Perhaps update the <a href="http://codex.wordpress.org/WordPress_Coding_Standards" rel="nofollow">WordPress Coding Standards</a>?</p>
php
[2]
573,200
573,201
htmlentities and french characters
<p>I am trying to escape some users input in form. </p> <pre><code>if( !empty($_SESSION['descr']) ) { $descr = htmlentities($_SESSION['descr']); $descr = stripslashes($descr); $descr = html_entity_decode($descr); echo"&lt;textarea cols=\"50\" rows=\"10\" name=\"descr\" &gt;".$descr."&lt;/textarea&gt;"; } else { echo "&lt;textarea cols=\"50\" rows=\"10\" name=\"descr\" &gt;&lt;/textarea&gt;"; } </code></pre> <p>I didn't use html_entity_decode() in the first place then I realized if a user put some French characters then it won't show them correctly. Is it save to use it the way it is with html_entity_decode()? </p>
php
[2]
1,273,426
1,273,427
Run a function in the background while starting another function
<p>I want to run a function in the background which checks every seconds a url.<br> I already have the function to check the url but I want to run this function every second and meanwhile I can start functions manually.<br> I hope you understand my question.</p> <p>Thanks</p>
java
[1]
1,130,153
1,130,154
I am having abc.mdf database in D drive and i want to use in my website using web.config?
<p>I am having abc.mdf database in D drive and i want to use in my website and i have tried as in web.config</p> <p></p> <p><strong>and i got following error</strong></p> <blockquote> <p>An attempt to attach an auto-named database for file D:\abc.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.</p> </blockquote> <p>I am sure database doesn't exists anywhere else.Please help</p>
asp.net
[9]
2,716,494
2,716,495
Iphone App contract-Entering Bank Details
<p>I have just got registered with iphone Dev program. in Itunes Connect,I only get FREE APPS contract. How can I enter Bank details before uploading any App?</p> <p>Thanks</p>
iphone
[8]
5,420,039
5,420,040
How come System.IO.File is returning false when the file does exist?
<p>I'm using <code>System.IO.File.Exists</code> to check if a file exists. However, it's returning false for a file that I know exists. The code is the following:</p> <pre><code>Assert.IsTrue(System.IO.File.Exists(@"\ImportRepositoryTest\Version2.xml")); </code></pre> <p>How come <code>System.IO.File</code> is returning false when the file does exist?</p>
c#
[0]
11,089
11,090
how to override this hashCode method?
<p>as for the definition of Person:</p> <pre><code>public class Person { private int id; private int characteristics; public boolean equals (Object obj) { if (obj == this) { return true; } if (obj instanceof Person) { if (id == ((Person) obj).id) { return true; } else if (characteristics == ((Person) obj).characteristics) { return true; } } return false; } } </code></pre> <p>cause 2 <code>Person</code> objects <code>a</code> and <code>b</code> must have the identical hash code if <code>a.equals(b)</code> returns <code>true</code>, how should I implement the <code>hashCode</code> method?</p> <p><strong>solution</strong></p> <p>my <code>equals</code> method implementation is incorrect according to Java's equivalence protocol: <em>transitivity</em> is not satisfied: <code>a.id = 1</code>, <code>a.characteristic = 2</code>, <code>b.id = 1</code>, <code>b.characteristic = 3</code>, <code>c.id = 2</code>, <code>c.characteristic = 3</code>; <code>a.equals(b) == true</code>, <code>b.equals(c) == true</code>, but <code>a.equals(c) == false</code>.</p>
java
[1]
2,015,556
2,015,557
Difference Dates Calculation
<p>I have three textboxes, <code>StartTextbox</code>, <code>EndTextBox</code>, and <code>Textbox3</code>, where <code>Textbox3</code> contains <code>No of Month</code>. Now I want difference of start date and end date to be checked against <code>No of Month</code>.</p> <p>Here is the custom validation function:</p> <pre><code>protected void ValidateDuration(object sender, ServerValidateEventArgs e) { DateTime start = DateTime.Parse(StartTextBox.Text); DateTime end = DateTime.Parse(EndTextBox.Text); int months = (end.Month - start.Month) + 12 * (end.Year - start.Year); e.IsValid = months &lt;= TextBox3; } </code></pre>
asp.net
[9]
507,853
507,854
Animation BEFORE activity change
<p>I'm trying to do something simple, but I can't understand why it's not working.<br> What I'm trying to do is: when I touch an ImageView, it will show an animation on it. And then, only when that animation ends it will start the new activity.<br> Instead, what happens is that the new activity starts right away and the animation is not shown.</p> <p>Here is the animation xml:</p> <pre><code>&lt;rotate android:interpolator="@android:anim/decelerate_interpolator" android:fromDegrees="-45" android:toDegrees="-10" android:pivotX="90%" android:pivotY="10%" android:repeatCount="3" android:fillAfter="false" android:duration="10000" /&gt; </code></pre> <p>And this is the code I use to call it:</p> <pre><code>public void onCreate( Bundle savedInstanceState ) { final ImageView ib = (ImageView)this.findViewById( R.id.photo ); ib.setOnClickListener( new OnClickListener( ) { @Override public void onClick( View v ) { Animation hang_fall = AnimationUtils.loadAnimation( Curriculum.this, R.anim.hang_fall ); v.startAnimation( hang_fall ); Intent i = new Intent( ThisActivity.this, NextActivity.class ); ThisActivity.this.startActivity( i ); }// end onClick } ); }// end onCreate </code></pre> <p>As you see I tried putting a loooong time for the animation, but it doesn't work. The NextActivity starts right away, it doesn't wait for the animation in ThisActivity to finish.<br> Any idea on why this happens?</p>
android
[4]
3,290,899
3,290,900
Stream context create not showing correct ouput?
<p>I am connecting up to an API and as a result it should loop and output 5 iterations of the results from the checks.</p> <p><strong>The code</strong></p> <pre><code>&lt;?php $i = 0; $opts = array( 'https'=&gt;array( 'method'=&gt;"POST", 'header'=&gt;"Accept-language: en\r\n" . "Cookie: foo=bar\r\n" ) ); $context = stream_context_create($opts); $fp = fopen('https://ssl.theapidomain.com.au/check.php?domain=testdomain&amp;suffixes=com.au', 'r', false, $context); while ($i &lt; 5) { fpassthru($fp); $out = explode('&lt;br&gt;', $fp); echo $out[0]; echo "&lt;br&gt;"; echo $out[1]; echo "&lt;br&gt;"; echo date('H:i:s'); echo "&lt;br&gt;"; $i++; } fclose($fp); ?&gt; </code></pre> <p><strong>The output</strong></p> <p>available: testdomain.com.au not available: whoisfailure: Resource id #2</p> <p>16:58:57</p> <p>Resource id #2</p> <p>16:58:57</p> <p>Resource id #2</p> <p>16:58:57</p> <p>Resource id #2</p> <p>16:58:57</p> <p>Resource id #2</p> <p>16:58:57</p> <p>It should be outputting this 5 times:</p> <p>available: testdomain.com.au not available: 16:58:57</p> <p>It seems when I echo $out[0] and [2], it displays the resource id rather than the information inside (available / not available).</p>
php
[2]
5,078,463
5,078,464
In Java, how do I dynamically determine the type of an array?
<pre><code>Object o = new Long[0] System.out.println( o.getClass().isArray() ) System.out.println( o.getClass().getName() ) Class ofArray = ??? </code></pre> <p>Running the first 3 lines emits;</p> <pre><code>true [Ljava.lang.Long; </code></pre> <p>How do I get ??? to be type long? I could parse the string and do a Class.forname(), but thats grotty. What's the easy way?</p>
java
[1]
5,661,149
5,661,150
Compare two time (hh:mm:ss) strings
<p>I have two time strings in <code>hh:mm:ss</code> format. (eg: <code>12:40:13</code> and <code>20:01:01</code>.) How can I compare these in JavaScript?</p>
javascript
[3]
938,336
938,337
how run bash script on client system to detalis system process
<p>i wnat to run a script on client system to get &amp; access imformation of client and using ubuntu</p>
javascript
[3]
151,828
151,829
PHP prepends backtick to all print and echo output
<p>This is a server-wide issue, not confined to this particular script, but I'll give code regardless.</p> <pre><code>include_once('LIB/LIB_data.php'); $id = $_GET['id']; $columns = Data::getTableColumns('table'); if(!in_array($id, $columns)) { exit("Illegal value"); } else { $dbh = new PDO('/* connects successfully */'); $sth = $dbh-&gt;prepare("SELECT DISTINCT $id FROM table"); $sth-&gt;execute(); $result = $sth-&gt;fetchAll(PDO::FETCH_ASSOC); $fields = array(); foreach($result as $set) { $val = $set[$id]; array_push($fields, "{\"optionValue\": \"$val\", \"optionDisplay\": \"$val\"}"); } $return_val = '[' . implode(",", $fields) . ']'; print($return_val); } </code></pre> <p>Should return something like this:</p> <pre><code>[{"optionValue": "f", "optionDisplay": "f"},{"optionValue": "m", "optionDisplay": "m"}] </code></pre> <p>Instead, it's this:</p> <pre><code>`[{"optionValue": "f", "optionDisplay": "f"},{"optionValue": "m", "optionDisplay": "m"}] </code></pre> <p>It works the same with echo. There's a backtick before absolutely everything that I output with either one. I don't use backticks anywhere. I'm on PHP 5.2.10, if that helps. This is a weird error I haven't been able to find mention of anywhere else, so any help would be greatly appreciated.</p>
php
[2]
1,800,281
1,800,282
How to change the class of an object dynamically in C#?
<p>Suppose I have a base class named Visitor, and it has 2 subclass Subscriber and NonSubscriber.</p> <p>At first a visitor is start off from a NonSubscriber, i.e.</p> <pre><code>NonSubscriber mary = new NonSubscriber(); </code></pre> <p>Then later on this "mary" subscribed to some services, and I want to change the type of "mary" to Subscriber.</p> <p>What is the conventional way to do that?</p>
c#
[0]
1,960,521
1,960,522
Need to check longest prefix of a number
<p>I've an array i.e. $arr(22, 123, 12345, 1234) After user input a value i.e. 123456789 I need to check longest prefix exist in array or not. In above input case $arr[2] will be answer. If input is 123000 the answer will be $arr[1]. Input can be of any length. </p> <p>Php hint will be appreciable </p>
php
[2]
2,280,508
2,280,509
How big is "too big" for a javascript file
<p>With all the awesome jQuery plug-ins out there, it's so tempting to just start including them all over the place to enhance the look of our website. </p> <p>I'm looking for some opinions on whether and when I should be concerned about the sizes of these scripts. </p> <p>Assume they're being cached on the web server level, so I guess the potential concerns are on bandwidth for the scripts being served from the web server, as well as performance on the client browser that needs to download all these scripts.</p>
javascript
[3]
2,374,543
2,374,544
preg_replace(), removing string containing '+' char
<p>I am having an issue removing "%3Cbr+%2F%3E" from my string using the preg_replace function. My assumption is that the '+' char is being interpreted incorrectly. Here my code:</p> <pre><code>$address = preg_replace('/%3Cbr+%2F%3E/', '', urlencode($address)); </code></pre> <p>Thanks as always!</p>
php
[2]