Unnamed: 0
int64
65
6.03M
Id
int64
66
6.03M
Title
stringlengths
10
191
input
stringlengths
23
4.18k
output
stringclasses
10 values
Tag_Number
stringclasses
10 values
3,937,443
3,937,444
what's the line meaning in jquery?
<pre><code> var selector = $('#foo'); var html = selector.wrap('&lt;div/&gt;').parent().html(); selector.unwrap(); </code></pre> <p>i am new to jquery, i don't understand the second line well, expect some can explain to me. thank you,</p>
jquery
[5]
4,661,942
4,661,943
Building iPhone App for Distribution
<p>I have a question on how exactly to do the final distribution build for my app. I have actually successfully built this app already but now I am trying to make an updated version and to remember what I did right the first time. It all seemed to go wrong when my provisioning profile expired....</p> <p>Anyway, I have my distribution certificate and distribution provisioning profile. I have followed the instructions from Apple, an iPhone programming book and several online sources to create a build that checks against the right certificate etc. But the build always fails unless I connect a device, which is strange as the distribution provisioning profiles do not allow the inclusion of a device (which makes perfect sense in itself). However when I build with a device connected I am asked </p> <blockquote> <p>'Can’t run XXX on the iPod “iPod touch”</p> <p>The iPod “iPod touch” doesn’t have the provisioning profile with which the application was signed.</p> <p>Click “Install and Run” to install the provisioning profile XXX on “iPod touch” and continue running XXX.'</p> </blockquote> <p>When I click install and run it fails with the message that </p> <blockquote> <p>A valid provisioning profile for this executable was not found.</p> </blockquote> <p>So my basic question is how exactly should the final distribution build be done? An new executable appears, but it has a forbidden symbol on top of the application icon suggesting the build was unsuccessful. </p> <p>Any help massively appreciated.</p>
iphone
[8]
829,081
829,082
Assembly Resolve Not Fully Loading My DLL?
<p>I'm using a method to load a dll on an AssemblyResolve event. It's not quite working the way I want it to. Here's some code:</p> <p>in my form load:</p> <pre><code>var a = AppDomain.CurrentDomain; a.AssemblyResolve += (object sender, ResolveEventArgs args) =&gt; LoadDLL(sender, args, anArg); </code></pre> <p>LoadDLL:</p> <pre><code>public Assembly LoadDLL(object sender, ResolveEventArgs agrs, bool anArg){ //Let's just ignore anArg, it doesn't affect anything related to the problem asseblyPath = @"XXX";//path to my dll return Assembly.LoadFrom(assemblyPath); } </code></pre> <p>So that's all well and good. I set Copy Local to false for my DLL so the AssemblyResolve event is called and I can load the desired version of my DLL. </p> <p>One strange thing that is happening is this: After running this code, my code tries to access a public variable from a class containing global constant values (this class should be in my DLL). </p> <pre><code>public class GCV{ public GCV(){} public string value1= "asdf"; } </code></pre> <p>Unfortunately, when I'm in debug mode, GCV.value1 is set to null when it clearly has a value in the class definition. This is one symptom that I can describe here, hopefully enough to diagnose the problem? </p> <p>Thanks!</p>
c#
[0]
4,311,083
4,311,084
How to stop python from looking for .py files
<p>I have a system with very little resources (embedded). Because of that I only installed the python .pyo files (=byte compiled &amp; optimized) for my program. Now when such a program runs, python keeps looking for .py files (probably to see if the .pyo needs to be updated). The funny thing is that it does that a lot: 25000 stat64() calls (and 8304 getcwd calls()) in 5 minutes!</p> <pre><code>getcwd("/tmp", 1026) = 9 getcwd("/tmp", 1026) = 9 stat64("MyProgram.py", 0xbeb94b0c) = -1 ENOENT (No such file or directory) stat64("/usr/local/lib/python2.5/MyProgram.py", 0xbeb94b0c) = -1 ENOENT (No such file or directory) stat64("/usr/local/lib/python25.zip/MyProgram.py", 0xbeb94b0c) = -1 ENOENT (No such file or directory) stat64("/usr/local/lib/python2.5/MyProgram.py", 0xbeb94b0c) = -1 ENOENT (No such file or directory) stat64("/usr/local/lib/python2.5/plat-linux2/MyProgram.py", 0xbeb94b0c) = -1 ENOENT (No such file or directory) stat64("/usr/local/lib/python2.5/lib-tk/MyProgram.py", 0xbeb94b0c) = -1 ENOENT (No such file or directory) stat64("/usr/local/lib/python2.5/lib-dynload/MyProgram.py", 0xbeb94b0c) = -1 ENOENT (No such file or directory) stat64("MyProgram.py", 0xbeb94cc8) = -1 ENOENT (No such file or directory) getcwd("/tmp", 1026) = 9 stat64("MyProgram.py", 0xbeb94bc4) = -1 ENOENT (No such file or directory) </code></pre> <p>How can I prevent python from doing this?</p>
python
[7]
2,983,926
2,983,927
Why can't you select top level elements in an HTML string with jQuery, and how do you get around it?
<p>I have some HTML stored in a string which I parse using jQuery. The HTML is something like:</p> <pre><code>&lt;div class='person'&gt; &lt;span class='name'&gt;Joey&lt;/span&gt; &lt;img class='avatar' src='...'/&gt; &lt;/div&gt; &lt;div class='person'&gt; &lt;span class='name'&gt;Dee Dee&lt;/span&gt; &lt;img class='avatar' src='...'/&gt; &lt;/div&gt; &lt;div class='person'&gt; &lt;span class='name'&gt;Tommy&lt;/span&gt; &lt;img class='avatar' src='...'/&gt; &lt;/div&gt; &lt;div class='person'&gt; &lt;span class='name'&gt;Johnny&lt;/span&gt; &lt;img class='avatar' src='...'/&gt; &lt;/div&gt; </code></pre> <p>So I use jQuery to parse the HTML like this (suppose the HTML is stored in the variable 'data'):</p> <p><code>$(".name", data)</code> returns all the .name elements</p> <p><code>$(".avatar", data)</code> returns all the .avatar elements</p> <p>BUT <code>$(".person", data)</code> returns and empty object. </p> <p><strong>So apparently jQuery cant parse the top level elements. Why is this? What is the best way to get around it?</strong> </p> <p>Of course I can always insert 'data' inside a dummy element and then parse it, but that doesn´t seem a very elegant solution to me...</p>
jquery
[5]
1,077,911
1,077,912
Receiving result from .ajax function in jQuery
<p>I have this code : </p> <pre><code>$.ajax({ type: "POST", url: "tosql.php", data: { content, content } }); </code></pre> <p>I was wondering how I could get a callback from tosql.php (the result) and add that html to <code>div class = "content"</code></p>
jquery
[5]
2,221,510
2,221,511
Jquery conflict problems with other scripts
<p>Hello on my website i am runnig many Jquery plugins like, carouFredSel, nivoslider, cloud-zom etc... they work fine, until i added this jquery script:</p> <pre><code>&lt;script type="text/javascript" src="jquery.lightbox_me.js" charset="utf-8"&gt;&lt;/script&gt; &lt;script type="text/javascript" charset="utf-8"&gt; $(function() { function launch() { $('#sign_up').lightbox_me({centered: true, onLoad: function() { $('#sign_up').find('input:first').focus()}}); } $('#try-1').click(function(e) { $("#sign_up").lightbox_me({centered: true, onLoad: function() { $("#sign_up").find("input:first").focus(); }}); e.preventDefault(); }); $('table tr:nth-child(even)').addClass('stripe'); $(".sign_up2").lightbox_me({centered: true, onLoad: function() { $(".sign_up2").find("input:first").focus(); }}); e.preventDefault(); }); &lt;/script&gt; </code></pre> <p>after adding this code, my slider stoped working and also image zoom... HO TO MAKE NON-CONFLICT? </p>
jquery
[5]
5,824,421
5,824,422
web portal development in java platform
<p>what is the tool to develop a web portal in java platform and what is the lanugage used in it core java or jsp.</p>
java
[1]
2,643,907
2,643,908
button should refer to itself in C#
<p>Assuming there are buttons with all the letters from the alphabet set as Text. I want to call a function in these buttons and use this letter as argument. Can I use the same piece of code for each button in some way?</p> <p>something like </p> <pre><code>functionname(this.Text); </code></pre> <p>Problem is, that "this" referrs to the Form and not to the specific button.</p>
c#
[0]
3,484,095
3,484,096
need to retrive information from the drop down when click on submit button
<p>when i select a value from the dropdown and then hit submit how can i retrive the information for what i have selected from the drop down from the database. Means i have created another colummn in the table so whats been selected in the drop down that information should pop-up which relates to that from the table</p>
php
[2]
2,193,223
2,193,224
Unique Bytes from a String
<p>I want to get bytes from a string value( for Encryption/Decryption purposes ), I have used getBytes() method for that purpose, but every time i call getBytes() method, it returns a new bytes of array each time. I want a unique bytes of array for a particular string. How ? Also i want to store that information (string or byte) in a file, and i want to get back this information in form of bytes.</p>
java
[1]
1,872,476
1,872,477
ajax response vs normal http response
<p>By checking the <code>x-requested-with</code> header we can check whether a request is an ajax or not, but how does the browser knows it's an ajax response and it need not be rendered, rather it needs to be handled by JS?</p>
javascript
[3]
3,634,282
3,634,283
Monopoly game 3D graphical interface
<p>I have created a Monopoly game with a 2D Graphics in Java for my final exam at college.</p> <p>I feel that the game doesn't look very good and I want to add a 3D Graphics. My problem is that I have never done 3D programming and I don't know how to create 3D objects.</p> <p>Can someone tell me where can I create 3D objects and what library to use for 3D programming that will allow me to create a 3D graphic interface fast? I have only two more weeks to do this. Can this be done?</p>
java
[1]
4,497,607
4,497,608
Best way to remove duplicate characters from a string?
<p>How can I remove duplicate characters from a string using Python? For example, Let's say I have a string:</p> <pre><code>foo = 'mppmt' </code></pre> <p>How can I make the string:</p> <pre><code>foo = 'mpt' </code></pre> <p>NOTE: Order is not important</p>
python
[7]
561,334
561,335
How to hyperlink a web address or a non web address in php
<p>I have a website were users enters articles and their reference(like wikipedia). The reference which were saved in the database includes both web address and non web addresses.Currently i am hyper linking the script using google's search?q and its working properly.</p> <pre><code> echo("&lt;br&gt;&lt;a rel=nofollow target=_blank href='http://www.google.com/search?q=".urlencode($row['ref'])."' class=art&gt;$row[ref]&lt;/a&gt;"); </code></pre> <p>i want to know whether its possible to automatically detect my reference as a web address or not .if it is a web address then when users click to the hyperlink it goes directly to that website and if not it should hyperlink to google search.</p> <p>eg:</p> <p>if user enters this link as reference.hyper link should be to this web address</p> <pre><code> http://www.washingtonpost.com/sports/capitals or www.washingtonpost.com/sports/capitals or washingtonpost.com/sports/capitals </code></pre> <p>or if the user enters reference as below </p> <pre><code> washingtonpost+sports+capitals </code></pre> <p>it should go to googles search?q</p> <p>advance thanks for your help</p>
php
[2]
93,552
93,553
Killing setInterval upon object deletion
<p>I have the following HTML page:</p> <pre><code>&lt;html&gt; &lt;script&gt; var global = {}; global.obj = { // when called this function will cause 'hello' to be output to the // console every 1 second repeat: function () { setInterval(function () { console.log('hello'); }, 1000); } } global.obj.repeat(); global.obj = []; // even after we overwrite global.obj, 'hello' // continues to be output to the console every second &lt;/script&gt; &lt;/html&gt; </code></pre> <p>I want to write a function similar to repeat, except when global.obj is overwritten, setInterval will stop being called</p>
javascript
[3]
3,022,063
3,022,064
Which JRE I am using
<p>There are 2 varieties of JRE available. <a href="http://stackoverflow.com/questions/338745/java-vm-ibm-vs-sun">Java VM: IBM vs Sun</a></p> <p>Is there any way to know which JRE I am using through java script or some java issued command.</p>
java
[1]
3,801,313
3,801,314
Counting instances of individual derived classes
<p>I'd like to be able to count instances of classes that belong in the same class hierarchy.</p> <p>For example, let's say I have this:</p> <pre><code>class A; class B: public A; class C: public B; </code></pre> <p>and then I have this code</p> <pre><code>A* tempA = new A; B* tempB = new B; C* tempC = new C; C* tempC2 = new C; printf(tempA-&gt;GetInstancesCount()); printf(tempB-&gt;GetInstancesCount()); printf(tempC-&gt;GetInstancesCount()); </code></pre> <p>the result of that should print<br> 1<br> 1<br> 2<br></p> <p>The counting, ideally, should be done internally. Each class, and not some kind of manager, should know how many instances it has.</p> <p>Any ideas?</p> <p>Thanks!</p>
c++
[6]
1,482,996
1,482,997
Select all my and my friend friends except us both SQL
<p>I have thee tables "user_follow", "images", "users"</p> <p>My user_id : 3 My Friend user_id : 6</p> <p>I need query to select all friends of me and my friend with their username and images 1) do not show us each other 2) duplicate friends show as 1</p> <p>My query is : </p> <pre><code> $sql = "SELECT u.username, i.image, u.id FROM users u LEFT JOIN user_follow f ON u.id = f.follow_id LEFT JOIN images i ON u.id = i.user_id WHERE f.user_id = 6 OR f.user_id = 3 GROUP BY u.id ORDER BY f.date DESC"; </code></pre> <p>and result is :</p> <pre><code>[user_both_follow] =&gt; Array ( [0] =&gt; Array ( [username] =&gt; Kolxoznik1 [image] =&gt; [id] =&gt; 1 ) [1] =&gt; Array ( [username] =&gt; 7777 [image] =&gt; [id] =&gt; 8 ) [2] =&gt; Array ( [username] =&gt; 6666 [image] =&gt; flw3utn9igiqh7dtt2o61ydf8_174.jpeg [id] =&gt; 6 ) [3] =&gt; Array ( [username] =&gt; 8888 [image] =&gt; [id] =&gt; 7 ) ) </code></pre> <p>My query works at 50% it group the same friends but problem is that show my friend 3->6 (show)</p>
php
[2]
5,157,597
5,157,598
How can I convert rtf file to pdf file using ABCpdf
<p>This is my code, when read the .rtf file that time through an exception that is "<strong>OpenOffice.org not available</strong>".</p> <p>file = File(scanDoc.Document, contentType, scanDoc.OriginalFilename);</p> <pre><code> string path = Server.MapPath("~/temp/" + file.FileDownloadName); Doc doc = new Doc(); doc.Save(path); XReadOptions readOptions = new XReadOptions(); readOptions.ReadModule = ReadModuleType.OpenOffice; doc.Read(path, readOptions); doc.Save("output.pdf"); doc.Clear(); </code></pre> <p>Please anybody can gives me a suggestion, how can I solve the problem.</p> <p>Thanks. </p>
c#
[0]
2,793,147
2,793,148
C++ signed char to double
<p>All,</p> <p>New to C++ and am having a small issue converting a signed char to a double. Initial idea was to convert the signed char to a const char* and use atof to return the double.</p> <pre><code>signed char x = '100'; const char * cChar = x; std::cout &lt;&lt; atof(cChar); </code></pre> <p>Ideas?</p>
c++
[6]
5,572,198
5,572,199
How to read file's content in php not from the beginning?
<p>On Windows OS, I have a file with size of 1 MB. I want to use PHP to read the file's content. I know there is the <code>fread</code> function to read file, however, I want to read the file not from the starting position but somewhere at the middle position. How do I do that?</p>
php
[2]
2,831,101
2,831,102
Override a default php function ? (eval)
<p><br> we can simply override a default php function by using the following code :</p> <pre><code>namespace blarg; function time() { echo "test !"; } time(); </code></pre> <p>but ! is it possible to override the "eval" functon ?</p> <pre><code>namespace blarg; function eval() { echo "test !"; } eval(); </code></pre> <p>?<br></p> <h2>thanks in advance</h2> <p>According to the answeres : </p> <ol> <li>eval() is a language construct and not a function, we can't override it <br> 2.Im not really overriding the time() function in my example. I'm just creating a blarg\time() function</li> </ol> <hr> <p>I understood <br> <strong>BUT</strong><br> Actually i'm writtin sumting like a debugger and i need to change the default behaviour of php functons or some language construct (e.g eval) Is there anyway to do this ? Is it possible to change the php source and compile it ? (Is there any specific file to edit ?)</p>
php
[2]
2,717,335
2,717,336
Clone elements of a list
<p>Let's say I have a Python list that looks like this:</p> <pre><code>list = [ a, b, c, d] </code></pre> <p>I am looking for the most efficient way performanse wise to get this:</p> <pre><code>list = [ a, a, a, a, b, b, b, c, c, d ] </code></pre> <p>So if the list is N elements long then the first element is cloned N-1 times, the second element N-2 times, and so forth...the last element is cloned N-N times or 0 times. Any suggestions on how to do this efficiently on large lists.</p>
python
[7]
3,404,269
3,404,270
Null Pointer Exception in Linked List
<p>Removed for academic integrity. Thank You.</p>
java
[1]
4,009,875
4,009,876
java / netbeans timer?
<p>I am working with stocks. I have an api (pre written), in which I have adjusted the code a bit to suit my requirements, such as getting tick feed to my requirement (one tick is minimum movement up or down +-.01 cent).</p> <p>TICK is the way to describe a stock movement e.g. TICK charts etc. In very simple language it's just a movement/price change, nothing else. </p> <p>The program prints out to the console when there has been three up ticks in a row or down ticks in a row.</p> <p>I would like to know, how do I configure my api for a break out? That means three ticks (price movement) or 4 ticks in a particular direction (last 4 prices of a stock were greater than the previous ones, e.g. $1.01 then $1.02 then $1.03 then 1.04) but all within a time frame, say 500 or 300 milliseconds.</p> <p>Is there a timer function? The api is written in net beans / java</p>
java
[1]
825,740
825,741
How to start a career in Java? Java SCJP Certificate?
<p>I am planning to write the SCJP exam soon, and I wonder if that will be helpful to get Graduate/Junior Java Programmer job. Exam seems to be easy to pass for some people.</p> <p><strong>What is the minimum scope of knowledge to start thinking about career in Java field?</strong></p> <p>Do you think that SCJP will be enough to dive in to Java world? </p> <p>If not, what advice would you give me? how to start a career in Java?</p> <p>Regards</p>
java
[1]
1,572,281
1,572,282
asp.net web.config encryption
<p>why is it considered correct practice to encrypt sensitive data in web.config before deployment? if the website is hosted on-site, how can it be a risk not to encrypt this data?</p>
asp.net
[9]
271,399
271,400
hiding window.location URL
<p>I'm new to the JavaScript thing. I have this script, all I need is to hide the url because it shows up in the message. if you look at window.location, you see the url that i want to hide in the prompt message, then the user will be redirected to that url. </p> <pre><code>&lt;script&gt; function confirmation() { var answer = confirm("Are You sure You want to cancel?") if (answer){ alert("No information saved!") window.location = "http://www.google.com"; } else{ alert("You may hit save to submit information") setTimeout('confirmation()',10000); } } &lt;/script&gt; </code></pre>
javascript
[3]
2,012,938
2,012,939
What HTTP header does HttpContext.Current.Request.IsSecureConnection look for?
<p>I assume that HttpContext.Current.Request.IsSecureConnection in ASP.NET looks at some HTTP Header to determine whether the connection is secure.</p> <p>Does anyone know which header is it looking at?</p>
asp.net
[9]
4,253,313
4,253,314
c# application encountering a problem and closing for no apparent reason. Possible problems with 3rd party dlls
<p>Hi All We're building a c# application which will sit on PC's in garbage trucks. Things work fine on our development machines but as always, problems start to arise when we deploy onto our target hardware. </p> <p>One in particular is giving us headaches. At random intervals we will get a windows message box popping up and saying that our application has encountered a problem and needs to be closed. </p> <p>The application still works fine while the dialog box is sitting there, and obviously it closes when you click the close button. The frustrating thing is we get no exceptions, nothing in any logs, nothing in the system activity log. My hunch that there's some problem happening in a 3rd party library which we are using for GPS, which is a .net wrapper for an unmanaged dll which we've had problems with before. What options do we have to try and debug this?? I'm relatively new to windows programming and wondering if there are programs we can use to track which parts of a dll are being called by our code.</p> <p>Cheers Nimai</p>
c#
[0]
3,358,524
3,358,525
jquery using html
<p>i want to know coding jquery by using html which helps to banners.............</p>
jquery
[5]
2,789,570
2,789,571
$('.selector').closest('div') for non click element
<p><strong>First Case</strong>:</p> <pre><code>&lt;div&gt; &lt;a href="#" onclick="doIt(this)"&gt;some job&lt;/a&gt; &lt;div&gt; </code></pre> <p>i can do:</p> <pre><code>&lt;script&gt; function doIt(caller){ alert($(caller).closest('div').html()); } &lt;/script&gt; </code></pre> <p><strong>Second Case:</strong></p> <pre><code>&lt;div id="divId"&gt; .... &lt;/div&gt; </code></pre> <p>i do </p> <pre><code>&lt;script&gt; alert($("#divId").html()); &lt;/script&gt; </code></pre> <p>how can i apply first case mecanism to second case with out onclick(this)?</p> <p>more details about question:</p> <p>First case, as i use of anchor onclick, i can get action source then it's parent.</p> <p>Second case, on the other hand, there is div block and after script block. they are rendered in the page, consequence there is no click event. i need some thing:</p> $(this).closest('div').html() <p>but it doesnt work</p>
jquery
[5]
2,975,844
2,975,845
Designing a web control with several controls, all programmably editable
<p>I need to design a web control which includes a poll, but also some images (image controls).</p> <p>If I add the image controls to the web control, how can I edit these image controls? I need a web control with polls and images but the ability to edit the source of the image through properties (e.g. WebControl1.Image1.source = "";).</p> <p>Thanks</p>
asp.net
[9]
1,161,352
1,161,353
Storing a reversed string
<p>I Want to store the reversed string a in b without any function.</p> <blockquote> <p>public static void main(String args[]) {</p> <pre><code> BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); String a=br.readLine(); String b; for(int x=0,y=a.length()-1;x&lt;a.length();x++,y--) { b.charAt(x)=a.charAt(y); } </code></pre> </blockquote> <p>But I get this error :</p> <blockquote> <pre><code> b.charAt(x)=a.charAt(y); ^ </code></pre> <p>required: variable</p> <p>found: value</p> <p>1 error</p> </blockquote> <p>Can you explain it and help me fix it ?</p>
java
[1]
2,285,420
2,285,421
Sending an image to email via PHP
<p>can you please help me with this code. i am trying to embed a image in my mail and its showing as string of alphanumeric ..</p> <pre><code>function send_mail_pear() { $crlf = "\n"; $to = "mail@mail.in"; $head = ("From: mail@mail.in". "\r\n"); $head .= "Content-type: text/html\r\n"; $head .= "Content-Type: image/jpeg"; $mime = new Mail_mime($crlf); echo $head. "&lt;br/&gt;"; $mime-&gt;setHTMLBody('&lt;html&gt;&lt;body&gt;&lt;img src="map_6.gif"&gt; &lt;p&gt;You see this image.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;'); $mime-&gt;addHTMLImage('map_6.gif', 'image/gif'); $subject = "Test mail"; $mailBody = $mime-&gt;get(); $mail =&amp; Mail::factory('mail'); echo $mailBody ; /*if(mail($to, $subject, $mailBody, $head)){ echo "successful"; } else { echo "Mail Not sent"; } } </code></pre>
php
[2]
5,081,751
5,081,752
Check a datetime in pythonlist and convert to string
<pre><code>lista = [datetimeobject,'test',32] </code></pre> <p>if any element in the list is a datetimeobject, I need to convert to date format(ie;<code>2012-01-01</code>) and wrap around a quote "'" ie;<code>'2012-01-01'</code></p> <p>How can I accomplish it?</p>
python
[7]
3,979,677
3,979,678
I'm trying to decipher my logcat info for an app that hangs up, and I need some pointers
<p>Here is some background on what I have going on. I am learning as I go, so I might have some difficuities with terminology. I have a main activity that needs to connect to a bluetooth module. The main activity creates an object called mChatService from another java file called BluetoothChatService.java.</p> <pre><code>private BluetoothChatService mChatService = null; </code></pre> <p>So, in the main activity I have a function that is called connectDevice(). According to my logcat this function is entered into as expected. But when it reaches as certian line of code it hangs up. The line of code is this, mChatService.connect(device,secure); Now by checking the logcat errors this is what I find:</p> <pre><code>1639 BluetoothService.cpp stopDiscoveryNative:D-bus error instopDiscovery: org.bluez.Error.Failed(invalid discovery session) </code></pre> <p>Also another window pops up next to my java files, that reads:</p> <pre><code>ActivityThread.deliverResults(ActitvityThread$ActivityClientRecord, List) line: 2655 </code></pre> <p>So, my question is, Is this enough info to suggest a possible explanation of the problem that is occuring? If not, what would be my next step in gathering info that might be useful for debugging?</p>
android
[4]
5,025,159
5,025,160
How to Assign ArrayList hashmap<String,Double[]> to List
<p>I'm trying to assign Hashmap values of Double[] to List, but it is throwing an error:</p> <blockquote> <p>"The method add(Double) in the type List is not applicable for the arguments (Double[])"</p> </blockquote> <pre><code>ArrayList&lt;HashMap&lt;String, Double[]&gt;&gt; arl = (ArrayList&lt;HashMap&lt;String, Double[]&gt;&gt;) pd.getArrayList(); List&lt;Double&gt; empid = new ArrayList&lt;Double&gt;(); Iterator itr = arl.iterator(); while (itr.hasNext()) { HashMap&lt;String, Double[]&gt; map = (HashMap&lt;String, Double[]&gt;) itr.next(); empid.add(map.get("id"))); } </code></pre> <p>How can I cast <code>Double[]</code> to <code>Double.Request</code>?</p>
java
[1]
3,470,375
3,470,376
What is the best way to store double dimension vector in c++?
<p>What is the best way to store double dimension vector in c++?</p> <pre><code>std::vector &lt;std::vector &lt;int&gt; &gt; m_vector(N, std::vector&lt;int&gt;(M)); ... int k = m_vector[i][j]; </code></pre> <p>How else?</p>
c++
[6]
4,309,772
4,309,773
jquery select divs that are not in an iframe
<p>I need select all div tags that are not in an iframe. what selector can I wrote for that? I need something similar to: <code>$("div:not(in iframe)")</code></p>
jquery
[5]
2,994,153
2,994,154
Removing %20 on output
<p>I use this code from aweber that passes user information from signup to the next page, here is the code from aweber </p> <pre><code>&lt;script type="text/javascript"&gt; var formData = function(){var query_string = (location.search)?((location.search.indexOf('#') != -1) ? location.search.substring(1, location.search.indexOf('#')) : location.search.substring(1)) : '';var elements = []; if(query_string){var pairs = query_string.split("&amp;"); for(i in pairs) { if (typeof pairs[i] == 'string') {var tmp = pairs[i].split("="); var queryKey = unescape(tmp[0]); queryKey = (queryKey.charAt(0) == 'c') ? queryKey.replace(/\s/g, "_") : queryKey;elements[queryKey] = unescape(tmp[1]); } } } return{display: function(key){if(elements[key]){document.write(elements[key]); }else {document.write("&lt;!--If desired, replace everything between these quotes with a default in case there is no data in the query string.--&gt;");}}}}();&lt;/script&gt; </code></pre> <p>then this is the code on the page to display name</p> <p><code>&lt;script type="text/javascript"&gt;formData.display("fullname")&lt;/script&gt;</code></p> <p>The example output will be FirstName%20LastName</p> <p>Is there a way that %20 will be removed?</p> <p>Im new to javascript. I really dont know about this.</p> <p>Thanks</p>
javascript
[3]
1,992,164
1,992,165
Change ListView icon depends on a value [Solved]
<p>i wonder how can i change a listview icon depend on a value came from the XML file i pulled to fill the list</p> <p>something like this :::</p> <p>i tried to make an if clause but it didn't work i don't know why :( </p> <pre><code>super.onCreate(savedInstanceState); setContentView(R.layout.lisplaceholder); Utilites temp = new Utilites(); ArrayList&lt;HashMap&lt;String, String&gt;&gt; mylist = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;(); String xml = XMLfunctions.getXML("http://www.akwad-arabia.com/android/test.php?user=1&amp;format=xml"); Document doc = XMLfunctions.XMLfromString(xml); int numResults = XMLfunctions.numResults(doc); /*if((numResults &lt;= 0)){ Toast.makeText(this, "Geen resultaten gevonden", Toast.LENGTH_LONG).show(); finish(); }*/ NodeList nodes = doc.getElementsByTagName("record"); for (int i = 0; i &lt; nodes.getLength(); i++) { HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;(); Element e = (Element)nodes.item(i); map.put("id", XMLfunctions.getValue(e, "id")); //map.put("name", XMLfunctions.getValue(e, "name")); //if (XMLfunctions.getValue(e, "id") == "22") map.put("name", XMLfunctions.getValue(e, "name")); //else // map.put("name", "asdasd"); mylist.add(map); //this. list.add(country); } ListAdapter adapter = new SimpleAdapter(this, mylist , R.layout.main, new String[] { "name" }, new int[] { R.id.item_name}); setListAdapter(adapter); </code></pre>
android
[4]
2,225,562
2,225,563
Comparing one 2D and one 1D array in C#?
<p>I just want to write code for comparing a 1D array with a 2D array... I am working on writing a compiler and want to compare a 1D array which contains my code and other 2D array in which I have made a symbol table. I have written code, but it's not working.</p> <pre><code>for (int x = 0; x &lt; symboltable1.Length; x++) { for (int y = 0; y &lt; symboltable1.Length; y++) { for (int z = 0; z &lt; text.Length; z++) { if (symboltable1[x,y] == text[z]) listBox2.Items.Add(text[z]); else MessageBox.Show("poor"); } } } </code></pre>
c#
[0]
462,392
462,393
Run a function a specified number of times
<pre><code>function runAgain() { window.setTimeout(foo, 100); } function foo() { //Do somthing runAgain(); } </code></pre> <p>I can use the above code to run a function infinite number of times with an interval of one second.</p> <p>What is the standard way of running a function defined number of times. Lets say, I want <code>foo()</code> to be run 5 times with an interval of 1 second.</p> <p><strong>EDIT</strong> It's said that global variables should be avoided in Javascript. Isn't there a better way?</p> <p>With input from answers, I created a function like this: (Working Example: <a href="http://jsbin.com/upasem/edit#javascript,html" rel="nofollow">http://jsbin.com/upasem/edit#javascript,html</a> )</p> <pre><code>var foo = function() { console.log(new Date().getTime()); }; var handler = function(count) { var caller = arguments.callee; //Infinite if (count == -1) { window.setTimeout(function() { foo(); caller(count); }, 1000); } if (count &gt; 0) { if (count == 0) return; foo(); window.setTimeout(function() { caller(count - 1); }, 100); } if (count == null) {foo(); } }; handler(-1); //Runs infinite number of times handler(0); //Does nothing handler(2); //Runs two times handler(); //Runs foo() one time </code></pre>
javascript
[3]
3,381,501
3,381,502
Is it possible to use multiple indexes in php?
<p>I would like to do something similar to the following.</p> <pre><code>$ind=array('a','b','c'); $arr['a']=1; $arr['b']=4; $arr['c']=7; $d= $arr[$ind]; print_r($d); </code></pre> <p>It obviously doesnt work and I was wondering if there is still a simple way to do it in 1 or two lines of code.</p> <p><strong>EDIT</strong></p> <p>Here is a better example to demonstrate what I mean.</p> <pre><code>$ind=array('a','c','b','d','e','a','a'); $arr['a']=1; $arr['b']=4; $arr['c']=7; $d=$arr[$ind]; </code></pre> <p>Now I want to receive that $d is equal to 1,7,4,1,1</p> <p>array_intersect_key doesnt work. Or at least I cant make it work for me. I was thinking array_walk and a lamda function or something. Anyone?</p> <p>NOTE: This syntax is available in Matlab (well, almost). So you could for example type:</p> <pre><code>arr=rand(20,1); ind=[1 2 10 2 1 1]; newArr=arr(ind); </code></pre> <p>and it would produce vector of length 6 with the values as indexed by the ind vector.</p>
php
[2]
5,500,804
5,500,805
Checking argv[] against a string? (C++)
<p>So I'm attempting to check the arguments that I'm inputting into my program, and one of them is either the word "yes" or "no", entered without the quotes. </p> <p>I'm trying to test equivalency ( if (argv[n] == "yes") ) but that seems to be returning false every time when the input is, in fact, yes(When I output it it confirms this). What am I missing here that I'm doing improperly? If I understand properly argv[n] returns a cstring that is null-terminated, so it should allow me to do this.</p>
c++
[6]
5,767,874
5,767,875
How to load DLL using ctypes in Python?
<p>Please provide me a sample explaining how to load &amp; call a funtions in c++ dll using Python?</p> <p>I found some articles saying we can use "ctypes" to load and call a function in DLL using Python. But i am not able to find a working sample?</p> <p>It would be great if anyone provide me an sample of how to do it.</p>
python
[7]
900,684
900,685
jQuery hover problem!
<p><a href="http://ftp.crashboxcreative.com/ftp/EastsideBaptist/EBC-Final/" rel="nofollow">http://ftp.crashboxcreative.com/ftp/EastsideBaptist/EBC-Final/</a></p> <p>I'm having a lot of trouble with a simple jquery show/hide effect.</p> <p>When you hover over the slider, nav buttons fade in. Likewise, they fadeout on mouseleave.</p> <p>The problem is, they fadein/fadeout when you hover over a button!</p> <p><strong>How can I make jQuery ignore a hover over the buttons?</strong></p> <p>Edit: Only hover on the #slider should trigger an effect. I'm using this plugin: <a href="http://cssglobe.com/post/5780/easy-slider-17-numeric-navigation-jquery-slider" rel="nofollow">http://cssglobe.com/post/5780/easy-slider-17-numeric-navigation-jquery-slider</a></p> <p>I don't think the markup can be easily changed...</p>
jquery
[5]
3,705,180
3,705,181
Casting to object from a collection vs using foreach
<p>I am a little confused about the difference between the two statements.</p> <p>This one works and prints out the property results just fine.</p> <pre><code>foreach( string key in result.Properties.PropertyNames ) { foreach( object property in result.Properties[key] ) { Console.WriteLine("{0}:{1}", key, property.ToString()); } } </code></pre> <p>and the following doesn't work. I thought by casting the specific property to object it would be the same thing but its obviously not:</p> <pre><code>foreach( string key in result.Properties.PropertyNames ) { if( key == "name" ) { Console.WriteLine("{0}:{1}", key, ((object)(result.Properties[key])).ToString() ); } } </code></pre> <p>I get the object type of <code>result.Properties[key]</code> printed instead.</p>
c#
[0]
565,907
565,908
How do I "re-register" callback jQuery event functions in the refreshed partial view
<p>I have a partial view need register several event callback functions for it, however whenever I refreshed the partial to load new data, the elements which have been registered with event callbacks will lost the registration, how should I handle this and if I use jQuery auto refresh function like:</p> <pre><code>var auto_refresh = setInterval( function () { $('#DivId').load(URL); }, 10000 ); </code></pre> <p>which will refresh a partial within DivId, how can I register callbacks then...Please help..</p>
jquery
[5]
980,147
980,148
How do I queue jobs for when I have network?
<p>I'm working on an app where I create entries in a database while offline. I need to be able to have the app push these entries to a web server when I get a data or WiFi connection, and then delete them from the queue, but not from the app's database. <strong>I'm wondering if there are any libraries that already do this?</strong> I'm willing to code my own if I need to, but I thought I'd ask on here and see if anyone's heard of anything.</p> <p>Thanks!</p>
android
[4]
4,992,259
4,992,260
Fullcalendar on IPhone
<p>Is it possible to use fullcalendar on iphone native app reading events from servlet on a remote server? Features required are Month, Week and Day view. No need of adding, editing or deleting events. Clicking on event display the summary of the event. I would be very happy if fullcalendar is capable of the same, if no what are the other solutions. Expecting your guidance.</p> <p>Thanks in advance</p>
iphone
[8]
1,417,148
1,417,149
How to select a certain text from text file and enter into text box
<p>Hi all I have a sql script in text file which is as follows</p> <pre><code>create view [dbo].[budget_change-22] as select projectname, projectnumber,location, client FROM OPENROWSET('SQLNCLI', 'SERVER=AABB1089\abcWORKSS_STO;UID=abcworkss;PWD=abcdef, 'SET NOCOUNT ON;SET FMTONLY OFF;EXEC abcworks_sto..SP_Budget_444 38') AS Workchanged_444 Go </code></pre> <p>Now in the above script i have to select Server value (AABB1089\abcWORKSS_STO), UID value(abcwork), Pwd value(abcdef) so that i can replace in text box and edit them to create a new text file with different name.</p>
c#
[0]
3,673,266
3,673,267
problem with C# printing from a serial buffer
<p>i have a program in C#. and i want to print out what the program gets from serial.</p> <pre><code>class Serial { public static void Main() { byte[] buffer = new byte[256]; using (SerialPort sp = new SerialPort("COM2", 6200)) { sp.Open(); //read directly sp.Read(buffer, 0, (int)buffer.Length); //read using a Stream sp.BaseStream.Read(buffer, 0, (int)buffer.Length); Console.WriteLine(buffer); } } } </code></pre> <p>The program writes out System.byte[] and then quits.</p>
c#
[0]
1,000,719
1,000,720
Can't move li elements from one unorderted list to another
<p>I have two un-ordered list</p> <pre><code>&lt;ul id="#list1"&gt; &lt;li&gt;one&lt;/li&gt; &lt;li&gt;two&lt;/li&gt; &lt;/ul&gt; &lt;ul id="#list2"&gt;&lt;/ul&gt; </code></pre> <p>and two buttons</p> <pre><code>&lt;input id="add" name="yt1" type="button" value="&lt;&lt;" /&gt;&lt;br /&gt; &lt;input id="remove" name="yt2" type="button" value="&gt;&gt;" /&gt; </code></pre> <p>If the button with the id add is pressed all elements from #list1 should be move to #list2. How do I move elements from one list to another using JQuery</p> <p>I though of something like the below, but not sure how to do the actual moving</p> <pre><code>$("#add").click(function(){ $("#list1 li").each(function(){ //Do not know what to put in here } }) </code></pre>
jquery
[5]
2,711,074
2,711,075
Every nth element in a jQuery set
<p>I wanna select every nth in a jQuery set of elements.</p> <p>Eg.</p> <ol> <li><p>How do I select every third (C and F) in</p> <pre><code>$('&lt;ul&gt;&lt;li&gt;A&lt;/li&gt;&lt;li&gt;B&lt;/li&gt;&lt;li&gt;C&lt;/li&gt;&lt;li&gt;D&lt;/li&gt;&lt;li&gt;E&lt;/li&gt;&lt;li&gt;F&lt;/li&gt;&lt;li&gt;G&lt;/li&gt;&lt;/ul&gt;') </code></pre></li> <li><p>How do I select all other elements that is not every third (A, B, D, E, G) of the same set?</p></li> </ol>
jquery
[5]
5,860,396
5,860,397
Script doesn't work with simple arithmetic
<p>that's part of my script:</p> <pre><code>var count = $(".sliderItem").length; if (count &lt; lp + 5) { alert("bp4"); var clips = count-l; alert("bp5"); } </code></pre> <p>so the problem is: 'bp4' is visible but 'bp5' not.</p> <p>when I change <code>var clips = count-1;</code> to <code>var clips = 1;</code> it works fine.</p> <p>Somebody have some idea?</p>
javascript
[3]
391,173
391,174
how to select second tab bar when start
<p>how to go 2nd tab bar when click ? is select always 1st tab bar i want to select 2nd tab bar when screen show tab bar my screen selec 1st tab bar <a href="http://imgur.com/VCDOK" rel="nofollow">http://imgur.com/VCDOK</a> i want to select 2nd tab bar when start like this <a href="http://imgur.com/uPSJ2" rel="nofollow">http://imgur.com/uPSJ2</a></p> <p>my code is below </p> <pre><code> public class TabBarActivity extends TabActivity { /** Called when the activity is first created. */ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main2); setTabs() ; } private void setTabs() { addTab("payments", R.drawable.tab_home, AgAppPaymentScreen.class); addTab("My Account", R.drawable.tab_home, AgAppMyAccountScreen.class); addTab("Spend Analyzer", R.drawable.tab_home, AgAppPaymentScreen.class); addTab("Notification", R.drawable.tab_home, AgAppPaymentScreen.class); addTab("Help", R.drawable.tab_home, AgAppPaymentScreen.class); } private void addTab(String labelId, int drawableId, Class&lt;?&gt; c) { TabHost tabHost = getTabHost(); Intent intent = new Intent(this, c); TabHost.TabSpec spec = tabHost.newTabSpec("tab" + labelId); View tabIndicator = LayoutInflater.from(this).inflate(R.layout.tab_indicator, getTabWidget(), false); TextView title = (TextView) tabIndicator.findViewById(R.id.title); title.setText(labelId); ImageView icon = (ImageView) tabIndicator.findViewById(R.id.icon); icon.setImageResource(drawableId); spec.setIndicator(tabIndicator); spec.setContent(intent); tabHost.addTab(spec); } } </code></pre>
android
[4]
4,977,386
4,977,387
Having trouble with Japanese character "〜" in Android
<p>I don't know how to read Japanese - I don't know what this character means. </p> <p>We are using encoding UTF-8 in our XML file and can see all other Japanese characters in our app except for "〜", which shows up as a box. "〜" shows up in Eclipse, tried replacing it with a tilde (~), but the tilde is smaller and looks slightly different (〜 vs ~) in our app.</p> <p>On Google Translate, it interprets the character as a tilde <a href="http://translate.google.com/#ja/en/%E3%80%9C" rel="nofollow">http://translate.google.com/#ja/en/%E3%80%9C</a></p> <p>In Android, we have used &amp;#12316; and \u301C but they both show up as boxes.</p> <p>An example of how the character is used "気分が悪いよ〜!"</p> <hr> <p>My question: This is the only character that's missing for us (we have an American Android phones and changed the language to Japanese). How do we make this character show up?</p>
android
[4]
2,232,344
2,232,345
main method in Python
<p>I have the following code, which has the following two problems:</p> <pre><code>Traceback (most recent call last): File "C:\Users\v\workspace\first\src\tests.py", line 1, in &lt;module&gt; class Animal: File "C:\Users\v\workspace\first\src\tests.py", line 39, in Animal File "C:\Users\v\workspace\first\src\tests.py", line 31, in main dog = Animal() NameError: global name 'Animal' is not defined </code></pre> <p>This code is from a tutorial, and in the tutorial it works fine. I have the Python 2.7 and use the PyDev plugin for Eclipse.</p> <pre><code> class Animal: __hungry = "yes" __name = "no name" __owner = "no owner" def __init__(self): pass def set_owner(self,newOwner): self.__owner= newOwner return def get_owner(self): return self.__owner def set_name(self,newName): self.__name= newName return def get_name(self): return self.__name def noise(self): print('errr') return def __hiddenmethod(self): print("hard to find") def main(): dog = Animal() dog.set_owner('Sue') print dog.get_owner() dog.noise() if __name__ =='__main__':main() </code></pre>
python
[7]
587,684
587,685
Does handler.post(Runnable r) block the MessageQueue?
<blockquote> <p>A Handler allows you to send and process Message and Runnable objects associated with a thread's MessageQueue. Each Handler instance is associated with a single thread and that thread's message queue. When you create a new Handler, it is bound to the thread / message queue of the thread that is creating it -- from that point on, it will deliver messages and runnables to that message queue and execute them as they come out of the message queue.</p> </blockquote> <p><a href="http://developer.android.com/reference/android/os/Handler.html" rel="nofollow">http://developer.android.com/reference/android/os/Handler.html</a></p> <p>Does this actually mean that the Runnable object will block the Messages posted after it? The messages and Runnable objects actually in one queue?</p> <p>The manual is little ambiguous to me.</p> <p>Thanks!</p>
android
[4]
1,926,345
1,926,346
Why create an anonymous function with a ! before it?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/3755606/what-does-the-exclamation-mark-do-before-the-function">What does the exclamation mark do before the function?</a> </p> </blockquote> <p>What's the point of the <code>!</code> in the snippet bellow?</p> <pre> !function ($) { // code }(window.jQuery); </pre> <p>This syntax is used extensively in <a href="http://twitter.github.com/bootstrap/javascript.html" rel="nofollow">Twitter's bootstrap.js</a></p>
javascript
[3]
3,546,127
3,546,128
How to implement video chat in my iphone application
<p>I want to implement video chating features in my iphone application.</p>
iphone
[8]
33,367
33,368
jQuery alert box not working
<p>I have a tiny bit of code thats meant to show a javascript alert when a select list is changed value, but it doesnt seem to be working, could anyone give me a hand and let me know where im going wrong.</p> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function(){ $("#sources").change(function(e) { alert('This is what an alert message looks like.'); }); }); </code></pre> <p></p> <p>HTML for the select is as follows:</p> <pre><code>&lt;select name="sources" id="sources" multiple="multiple"&gt; &lt;option value=""&gt;please select&lt;/option&gt; &lt;option value="5"&gt;Seek&lt;/option&gt; &lt;option value="6"&gt;friends&lt;/option&gt; &lt;/select&gt; </code></pre>
jquery
[5]
3,753,644
3,753,645
Press exact same key in another computer(Replicate Key action)
<p>I have a situation where i want to replicate the action of the keys in another computer in a network. For example if i press "abcd" it should have same effect in the computer connected in network. Similar goes to BACKSPACE and any other keys. I tired using Java robot class but didn't get the exact result. Is there any way using Keylistener or Actionlistener or anything that can do this job ?</p>
java
[1]
2,990,534
2,990,535
how to find list of modules which depend upon a specific module in python
<p>In order to reduce development time of my Python based web application, I am trying to use reload() for the modules I have recently modified. The reload() happens through a dedicated web page (part of the development version of the web app) which lists the modules which have been recently modified (and the modified time stamp of py file is later than the corresponding pyc file). The full list of modules is obtained from sys.modules (and I filter the list to focus on only those modules which are part of my package).</p> <p>Reloading individual python files seems to work in some cases and not in other cases. I guess, all the modules which depend on a modified module should be reloaded and the reloading should happen in proper order. </p> <p>I am looking for a way to get the list of modules imported by a specific module. Is there any way to do this kind of introspection in Python?</p> <p>I understand that my approach might not be 100% guaranteed and the safest way would be to reload everything, but if a fast approach works for most cases, it would be good enough for development purposes. </p> <p><strong>Response to comments regarding DJango autoreloader</strong></p> <p>@Glenn Maynard, Thanx, I had read about DJango's autoreloader. My web app is based on Zope 3 and with the amount of packages and a lot of ZCML based initializations, the total restart takes about 10 seconds to 30 seconds or more if the database size is bigger. I am attempting to cut down on this amount of time spent during restart. When I feel I have done a lot of changes, I usually prefer to do full restart, but more often I am changing couple of lines here and there for which I do not wish to spend so much of time. The development setup is completely independent of production setup and usually if something is wrong in reload, it becomes obvious since the application pages start showing illogical information or throwing exceptions. Am very much interested in exploring whether selective reload would work or not. </p>
python
[7]
3,808,755
3,808,756
debug and inspect $_POST
<p>Lets say that i have 2 pages: index.php and service.php</p> <p>index.php sends an http-post to service.php, containing a datestamp once every 5th minute.</p> <p>How would i debug the post variables on service.php? Obviously i cant just do a </p> <pre><code>if(isset($_POST['key'])) { var_dump($_POST['key']); } </code></pre> <p>since it wont exist when i enter the page. </p> <p>In ASP.NET i would just create a breakpoint, but how would i inspect the posted data in php?</p> <p>Thanks</p>
php
[2]
1,719,531
1,719,532
PHP Multiply String Values from service
<p>I'm trying to multiply a value (sales tax) that is being returned from a service. I'm able to 'add' it without any problems, but I'm not able to get it to multiply using my string: </p> <pre><code>floatval(($service-&gt;PRICE)+floatval($service-&gt;SALES_TAX)+floatval($service-&gt;TRAVEL)) </code></pre> <p>I've tried using:</p> <pre><code>floatval(($service-&gt;PRICE)*floatval($service-&gt;SALES_TAX)+floatval($service-&gt;TRAVEL)) </code></pre> <p>and also</p> <pre><code>floatval(($service-&gt;PRICE*$service-&gt;SALES_TAX)+floatval($service-&gt;TRAVEL)) </code></pre> <p>But both only return the Travel amount, instead of the Price * Sales Tax + Travel.</p> <p>Any help is greatly appreciated!</p>
php
[2]
2,627,195
2,627,196
python and DB connection abstraction?
<p>Is there some module to allow for easy DB provider configuration via connection string, similar to PHP's PDO where I can nicely say "psql://" or "mysql://" or, in this python project, am I just going to have to code some factory classes that use MySQLdb, psycopg2, etc?</p>
python
[7]
3,723,059
3,723,060
Integer.toString(int i) vs String.valueOf(int i)
<p>I am wondering why the method <code>String.valueOf(int i)</code> exists ? I am using this method to convert <code>int</code> into <code>String</code> and just discovered the <code>Integer.toString(int i)</code> method.</p> <p>After looking the implementation of these methods I saw that the first one is calling the second one. As a consequence all my calls to <code>String.valueOf(int i)</code> involve one more call than directly calling <code>Integer.toString(int i)</code></p>
java
[1]
5,798,127
5,798,128
Check if $_POST exists
<p>I'm trying to check whether a $_POST exists and if it does, print it inside another string, if not, don't print at all.</p> <p>something like this:</p> <pre><code>$fromPerson = '+from%3A'.$_POST['fromPerson']; function fromPerson() { if !($_POST['fromPerson']) { print '' } else { print $fromPerson }; } $newString = fromPerson(); </code></pre> <p>Any help would be great!</p>
php
[2]
5,618,797
5,618,798
difference between errors and unchecked exceptions in java?
<p>As we know if any error or any unchecked exception occurs then our program will halt, then what are the differences between those?</p>
java
[1]
1,733,734
1,733,735
Most elegant way to modify Python list elements inplace
<p>I have a 2D list that looks like this:</p> <pre><code>table = [['donkey', '2', '1', '0'], ['goat', '5', '3', '2']] </code></pre> <p>I want to change the last three elements to integers, but the code below feels very ugly:</p> <pre><code>for row in table: for i in range(len(row)-1): row[i+1] = int(row[i+1]) </code></pre> <p>But I'd rather have something that looks like:</p> <pre><code>for row in table: for col in row[1:]: col = int(col) </code></pre> <p>I think there should be a way to write the code above, but the slice creates an iterator/new list that's separate from the original, so the references don't carry over. </p> <p>Is there some way to get a more Pythonic solution?</p>
python
[7]
3,922,551
3,922,552
MAIL NOT SHOWING UP
<pre><code>&lt;?php $to = 'something@gmail.com'; $subject = 'the subject'; $message = 'hello'; $headers = 'From: example@test.com' . "\r\n" . 'Reply-To: example@test.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers); $send = mail($to, $subject, $message, $headers ); if ($send) $mailReturns = "Mail sent successfully."; else $mailReturns = "Mail sent failed."; ?&gt; &lt;?php echo $mailReturns; ?&gt; </code></pre> <p>after run it shows mail sent successfully but mail not showing up in any of the accounts. iv tried gmail, yahoo, rediff and ibibo why???? </p>
php
[2]
5,112,393
5,112,394
ajax post with jQuery
<p>Is it possible to submit with POST method an ID when an element is clicked? I think jQuery has a built in AJAX fanction...</p> <pre><code>&lt;span id="submitThisID"&gt;&lt;/span&gt; </code></pre>
jquery
[5]
4,921,738
4,921,739
Translate post title to something url-firendly
<p>I have a site where people post stories, and I want part of each stories title to be included in the url that points to the story.</p> <p>For example if a poster posts a story titled "this is an example post", I am looking for a way to translate it to "this-is-an-example-post".</p> <p>Also, because the title will be used in a URL I need to filter out all the reserved or potentially dangerous characters.</p> <p>Is there an already made way (function library whatever) to do that or I will have to write my own?</p>
php
[2]
1,684,572
1,684,573
show and hide some span text
<p>I just started programming and learning Jquery, I'm trying to build a simple show/hide text button, and I actually almost made it succesfully, but the problem is I have two buttons and two texts to show/hide, but when I click either of the buttons both texts show/hide. here's my code:</p> <p>HTML:</p> <p></p> <pre><code>&lt;div class="mestre"&gt; &lt;h2&gt;Title&lt;/h2&gt; &lt;p&gt;some text&lt;/p&gt; &lt;h4&gt;Saiba mais&lt;/h4&gt;&lt;--the button --&gt; &lt;span class="saibamais"&gt;hidden text&lt;/span&gt;&lt;/div&gt; &lt;div class="mestre"&gt; &lt;h2&gt;Title&lt;/h2&gt; &lt;p&gt;some text&lt;/p&gt; &lt;h4&gt;Saiba mais&lt;/h4&gt;&lt;--the button --&gt; &lt;span class="saibamais"&gt;hidden text&lt;/span&gt;&lt;/div&gt; </code></pre> <p>JS </p> <pre><code> var saibamaisBtn = $('#conteudo div.mestre h4'); saibamais = $('#conteudo div.mestre span.saibamais'); $(function(){ saibamais.css('display', 'none'); }); saibamaisBtn.hover(function(){ var $this = $(this); $this.css('text-decoration', 'none'); }, function(){ $(this).css('text-decoration', 'underline'); }); saibamaisBtn.click( function() { saibamaisBtn.next('span').slideToggle('fast') } ); </code></pre>
jquery
[5]
2,449,799
2,449,800
javascript check radio buttons automatically
<p>I wanna check radio buttons automatically: I tried this code but it does not work: Radio buttons have 3 different values, I wanna select the radio button with value 'clean".</p> <p>How can I check automatically radio buttons on a webpage? Thanks!</p> <pre><code>function getElements() { for (i=0; i&lt;document.getElementsByTagName('input').length; i++) { //if (document.getElementsByTagName('input')[i].type == 'radio') if(document.getElementsByTagName('input')[i].type=='radio') { //if (document.getElementsByTagName('input')[i].value=='clean') document.getElementsByTagName('input')[i].click(); } } </code></pre> <p>I modified the code as following: </p> <pre><code> for (i=0; i&lt;document.getElementsByTagName('input').length; i++) { if(document.getElementsByTagName('input')[i].type=='radio') { if(document.getElementsByTagName('input')[i].value == "clean") { document.getElementsByTagName('input')[i].checked =true; } } } </code></pre> <p>but it is not still working:(</p> <p>the radio buttons are in a iframe, can it be the reason why the code is not working?</p>
javascript
[3]
1,924,587
1,924,588
How to unrar in Objective-C (iPhone)?
<p>I need to unrar some files in Objective-C (iPhone). I tried to compile the unrar sources in xcode, but failed.</p> <p>Appreciate it if some experts could teach me how to unrar in Objective-C (iPhone).</p> <p>Any suggestions is welcome. Thank you.</p>
iphone
[8]
3,908,349
3,908,350
Javascript error
<p>I'm getting a JS error on displaying a page: Nothing concrete is specified but the line where it seems to be thrown. When looking into the source code of the page, I see the error is thrown inside the following script, but I can't understand why! It's only about loading images!</p> <pre><code> &lt;SCRIPT language=JavaScript&gt; &lt;!-- function newImage(arg) { var rslt = new Image(); rslt.src = arg; return rslt; } function changeImages(a, b) { a.src = b; } newImage("\/_layouts\/images\/icon1.gif"); newImage("\/_layouts\/images\/icon2.gif"); // --&gt; &lt;/SCRIPT&gt; </code></pre> <p>The error I am getting is when clicking on a drop down context menu on a page, for this line:</p> <pre><code>newImage("\/_layouts\/images\/icon1.gif"); </code></pre> <p>Error: The object doesn't accept this property or method Code: 0</p> <p>I really don't see what could happen... Any tips on what may be happening here?<br> Thanks a lot!</p>
javascript
[3]
4,644,556
4,644,557
Does Android ImageView check image rotation?
<p>Does Android ImageView check image rotation? Or I should do it manually using ExifInterface?</p>
android
[4]
3,337,865
3,337,866
where to start OpenID implementation in python,which API is better suits
<p>im using python API in our research project.i read lot of ppt and material, and finally understand this concept now i have task to execute simple function which is chek user credential thorough openid provider and return successful after the valid user check.....</p>
python
[7]
1,592,044
1,592,045
Textarea and Textbox in asp.net
<p>We are able to provide a connection to a textbox using ADO.net to the database...but if we are willing to specify a particular region for our text then we are unable to use textarea in this case as far as sql connection through sql server is concerned.We are bound to use multiline textbox for this situation.Why textarea doesn't support connectin with the database? Can anybody help me out???</p>
asp.net
[9]
1,422,996
1,422,997
set operation on a property return IList is not working
<p>I have an interface with:</p> <pre><code>IList&lt;int&gt; CategoryIDs {get;set;} </code></pre> <p>Then a class that inherits this interface:</p> <pre><code>public IList&lt;int&gt; CategoryIDs { get {} // this part works set { _categoryIDs = value; // error! } </code></pre> <p>The set part of the accessor reports an error:</p> <blockquote> <p>cannot implicity convert type <code>IList&lt;int&gt;</code> to <code>List&lt;int&gt;</code>.</p> </blockquote> <p>What should I do? confused.</p>
c#
[0]
4,537,035
4,537,036
How do you calculate the distance between two points in GPS JAVA?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/27928/how-do-i-calculate-distance-between-two-latitude-longitude-points">How do I calculate distance between two latitude longitude points?</a> </p> </blockquote> <p>How do you calculate the distance between two points that are in latitude and longitude values in JAVA?</p> <p>Thanks</p>
java
[1]
5,802,837
5,802,838
what's the 'index' term on inspect.getouterframes() function?
<p>I did a "help(inspect.getouterframes)" on python, and here's what it gave me:</p> <pre><code>getouterframes(frame, **context**=1) Get a list of records for a frame and all higher (calling) frames. Each record contains a frame object, filename, line number, function name, a list of lines of context, and **index within the context**. </code></pre> <p>I'm just wondering...what do these "context" and "index" mean?</p> <p>Thanks!</p>
python
[7]
2,724,495
2,724,496
C# modulus operator
<p>I can write the program</p> <pre><code>int a = 3; int b = 4; Console.WriteLine(a % b); </code></pre> <p>The answer I get is 3. How does 3 mod 4 = 3??? </p> <p>I can't figure out how this is getting computed this way.</p>
c#
[0]
3,921,030
3,921,031
android hidden webview, Is it possible?
<p>I want to build an application which takes user/pass information from user and use it on an https webpage and extract the returned raw html code from that page.</p> <p>I want to know is this possible?</p> <p>If so, what sort of class i should use. Can it be done with some hidden webview mechanism. Sine i think we can access the java script variable in a webview from our application. So is this possible. Or i am just wasting my time in this direction.</p>
android
[4]
1,407,257
1,407,258
Cross-site communication - How its possible. Need a better Idea
<ol> <li>A link will be provided for the WebSiteA to WebSiteB</li> <li>We are not able to code anything in WebSiteA</li> <li>I need to pass a token from WebSiteA to WebSiteB (In order to understand the user is coming from WebSiteA)</li> <li>Can't use <code>Request.UrlReferrer</code> to identify previous site since WebSiteA is HTTPS</li> <li>Query string is insecure because of replay attack (If any outside get the url it can be re-used)</li> </ol>
asp.net
[9]
2,653,817
2,653,818
fputcsv Gives Warning When Handling Final Element of an Array
<p>My question is about how to properly handle the following warning:</p> <pre><code>Warning: fputcsv() expects parameter 2 to be array, boolean given </code></pre> <p>The offending lines are:</p> <pre><code>foreach($participantInfo as $fields) { fputcsv($participantFile, $fields); } </code></pre> <p>When I did a var_dump on <code>$fields</code>, I found two arrays as expected, but also a final <code>bool(false)</code>. Other than this, the code works as expected. Is there an appropriate way to handle the final bool, or should I just suppress the function warnings?</p>
php
[2]
1,135,427
1,135,428
Can I change the apps view based on if a file has been saved?
<p>Please help! I'm a newbie to programming and I'm having the following trouble. I am trying to write my first iphone app and I would like it to do the following.</p> <p>When the app launches user enters name, presses button and goes to new view. Their name is saved to file and used through out the app. That much I have managed.</p> <p>I would like the app to check to see if there is a saved file when it is launched and go directly to second view instead of the first view. I'm have search for days looking for an answer and I'm still not sure how to do this.</p> <p>At the risk of seeming stupid do I use an IF statement and how do I write it. Please help.</p> <p>Thanking you in advance.</p>
iphone
[8]
3,440,566
3,440,567
Android - failed to open zip archive
<p>I am downloading apk file from web and storing him into Context.getCacheDir(). I am downloading file by HttpURLConnection - I am not asking actually on the code (it is fully working), so I am not posting it here. I successfully initiate download. File is downloaded into cache and then is prompted installation - but system cannot open my APK and writes error of analysis.</p> <p>Hence problem is as follows:</p> <pre><code>03-31 16:48:43.740: INFO/ActivityManager(59): Start proc com.android.packageinstaller for activity com.android.packageinstaller/.PackageInstallerActivity: pid=620 uid=10026 gids={} 03-31 16:48:44.749: WARN/zipro(620): Unable to open zip '/data/data/com.my.app/cache/myApp.apk': Permission denied 03-31 16:48:44.749: DEBUG/asset(620): failed to open Zip archive '/data/data/com.my.app/cache/myApp.apk' 03-31 16:48:44.930: WARN/PackageParser(620): Unable to read AndroidManifest.xml of /data/data/com.my.app/cache/myApp.apk 03-31 16:48:44.930: WARN/PackageParser(620): java.io.FileNotFoundException: AndroidManifest.xml </code></pre> <p>Problem is - I don't have permission to access programaticaly /cache. Is there any way how to solve it? I don't want to use external storage as a download directory (installation process works when I download file to external storage), cache is great because the file won't be accessible for general user from file manager and that's what I want. Thanks for your thoughts.</p> <p>This problem has been for me unsolvable for over a month now...</p> <p><strong>Edit:</strong> Still no solution, I am trying to think that I found 1st thing, that is not possible with Android</p> <p><strong>Edit2:</strong> I must have been looking bad - my downloaded apk is present in cache... There is still no permission to allow install from that dir?</p>
android
[4]
1,161,803
1,161,804
C++ for Game Programming - Love or Distrust?
<p>In the name of efficiency in game programming, some programmers do not trust several C++ features. One of my friends claims to understand how game industry works, and would come up with the following remarks:</p> <ul> <li>Do not use smart pointers. Nobody in games does.</li> <li>Exceptions should not be (and is usually not) used in game programming for memory and speed.</li> </ul> <p>How much of these statements are true? C++ features have been designed keeping efficiency in mind. Is that efficiency not sufficient for game programming? For 97% of game programming? </p> <p>The C-way-of-thinking still seems to have a good grasp on the game development community. Is this true?</p> <p>I watched another video of a talk on multi-core programming in GDC 2009. His talk was almost exclusively oriented towards Cell Programming, where DMA transfer is needed before processing (simple pointer access won't work with the SPE of Cell). He discouraged the use of polymorphism as the pointer has to be "re-based" for DMA transfer. How sad. It is like going back to the square one. I don't know if there is an elegant solution to program C++ polymorphism on the Cell. The topic of DMA transfer is esoteric and I do not have much background here. </p> <p>I agree that C++ has also not been very nice to programmers who want a small language to hack with, and not read stacks of books. Templates have also scared the hell out of debugging. Do you agree that C++ is too much feared by the gaming community?</p>
c++
[6]
1,944,861
1,944,862
jQuery accordion plugin won't work once used in WP
<p>I'm tryin to use this accordion script in my WP: <a href="http://www.armagost.com/zaccordion/" rel="nofollow">http://www.armagost.com/zaccordion/</a></p> <p>Problem is that on a standalone html/php file it works well but once pasted in my header.php file there's no way to make it work. I tried also including it with <code>&lt;?php require_once("example.php") ?&gt;</code> but no success.</p> <p>You can see my header.php file here: <a href="http://pastebin.com/SrkmWxp1" rel="nofollow">http://pastebin.com/SrkmWxp1</a></p> <p>Thanks for your help.</p>
jquery
[5]
2,057,807
2,057,808
Bottom Tab Bar in Android
<p>I have made a bottom tab bar in the application.What I want is that when I click on that tab bar. A new Menu Type List should be <code>Opened/PopUp</code> and when i click on any of the list it should pop down Back.</p> <p>I know how to create seperate activity but dont know how to create the Menu Type Pop-Up list. </p>
android
[4]
869,612
869,613
What does this type of Object mean?
<pre><code>HttpEntity&lt;?&gt; requestEntity = new HttpEntity&lt;Object&gt;(json, headers); </code></pre> <p>I have a couple of questions here?</p> <ol> <li>What does the <code>?</code> mean here. Why have they put <code>&lt;?&gt;</code> instead of <code>&lt;Object&gt;</code></li> <li>Why does the HTTPEntity Constructor take &lt;<code>Object</code>> as its type but the Class Reference taking &lt;<code>?</code>> as its type.</li> </ol>
java
[1]
3,416,017
3,416,018
Cross platform way of clearing the screen in Python
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/2084508/clear-terminal-in-python">clear terminal in python</a> </p> </blockquote> <p>I have a Python script that I am targetting Windows and Linux users with -- the script runs from the command line only.</p> <p>Before starting the script, I'd like to clear the screen. The best I could come up with was using the <code>platform</code> module and then calling <code>subprocess</code>.</p> <pre><code>&gt;&gt;&gt; if platform.system() == 'Linux': # call clear </code></pre> <p>The same goes for Windows, where I call <code>cls</code>.</p> <p>Is this good or I can do better? </p>
python
[7]
5,448,091
5,448,092
Where to restore instance state?
<p>I need to save some state when the user leaves my game during game play. Saving the state doesn't seem to be an issue, but I can't figure out how to restore it. The <code>onCreate</code> function isn't called when the <code>Activity</code> is resumed (only when it is first created), so I can't get my state back there. Logically, I would use <code>onRestoreInstanceState</code>, but it isn't being called.</p> <pre><code>@Override protected void onRestoreInstanceState(Bundle savedInstanceState) { super.onRestoreInstanceState(savedInstanceState); Log.d("RocketLaunch", "onRestoreInstanceState()"); savedState = savedInstanceState; } </code></pre> <p>I see log output from <code>onSaveInstanceState</code>, <code>onResume</code>, <code>onCreate</code>, etc, but I never see a log message from <code>onRestoreInstanceState</code> and <code>savedState</code> is always null. Why isn't <code>onRestoreInstanceState</code> being called, and is there another way to get my state back?</p> <p>Thanks!</p>
android
[4]
4,777,271
4,777,272
How can I make my message <ul> element appear with jQuery when I post a message?
<p>I have the following HTML:</p> <pre><code>&lt;ul class="message" style="border-width: 1px 0 0 0; border-top-left-radius: 0; border-top-right-radius: 0;"&gt; &lt;/ul&gt; </code></pre> <p>and this code that sets $message:</p> <pre><code>oLink.$message = oLink.$modal.find('.message'); </code></pre> <p>I have the following javascript that adds a message:</p> <pre><code>obj.$message.html("&lt;li&gt;Contacting Server, please wait ...&lt;/li&gt;"); </code></pre> <p>This works but the problem is that when there is no message my ul is still styled with some properties that give it a height and make it show as an area at the bottom of my screen. Is there some way that I could make the message invisible and then have it show up. I am not very good at jQuery but could I chain in a show or hide into when I am creating a new message?</p>
jquery
[5]