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,810,586
5,810,587
How to trim document.getElementbyId value in JavaScript?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/196925/what-is-the-best-way-to-trim-in-javascript">What is the best way to trim() in javascript</a> </p> </blockquote> <p>How to trim document.getElementbyId value in JavaScript?</p>
javascript
[3]
2,541,883
2,541,884
Multiple apk based on density
<p>I want to upload 3 apk on android market based on density that is ldpi,mdpi and hdpi.</p> <p>I referred this links <a href="http://developer.android.com/guide/appendix/market-filters.html#MultiApks" rel="nofollow">http://developer.android.com/guide/appendix/market-filters.html#MultiApks</a> <a href="http://developer.android.com/guide/market/publishing/multiple-apks.html#HowItWorks" rel="nofollow">http://developer.android.com/guide/market/publishing/multiple-apks.html#HowItWorks</a></p> <p><a href="http://developer.android.com/guide/practices/screens_support.html#testing" rel="nofollow">http://developer.android.com/guide/practices/screens_support.html#testing</a></p> <p>How can I use below tag in manifest</p> <pre><code>&lt;compatible-screens&gt;&lt;/compatible-screens&gt; </code></pre> <p>My application size in large so i want to delete resources based on density and making build according to density</p> <p>Is this a proper way??</p> <p>plz help me</p> <p>Thanks in advance </p>
android
[4]
5,499,327
5,499,328
Automatically install/uninstall an application from within another application
<p>I am developing an Android device management service. </p> <p>One of the functions for this is specifying what apps should be installed on registered devices of the service.</p> <p>The scenario is that a manager will upload an enterprise app to the service for use on his employees' Android devices.</p> <p>He then asks the service to deploy the app. The service communicates with a pre-installed app on the devices. This app downloads the enterprise app then installs it without any confirmation from the user. </p> <p>Another requirement of this is that the user is prevented from installing or un-installing applications themselves.</p> <p>I have been looking at the android.app.admin package but the policy functionality seems limited. I have also discovered that it is possible to donwnload an APK then fire an intent to install it. However this needs confirmation from the user.</p> <p>In short, is it possible to install an Android application from within another application without any confirmation from the user whatsoever?</p>
android
[4]
2,862,628
2,862,629
Can AtomicInteger replace synchronized?
<p>The javadoc for the java.util.concurrent.atomic package says the following:</p> <blockquote> <p>A small toolkit of classes that support lock-free thread-safe programming on single variables.</p> </blockquote> <p>But I don't see any thread-safe (synchronized or Lock) code inside any of the AtomicInteger or AtomicBoolean classes.</p> <p>So, are these 2 the same:<p> 1. </p> <pre><code>int i; synchronized(this){i++;} </code></pre> <p>2.</p> <pre><code>AtomicInteger i = new AtomicInteger(); i.getAndIncrement(); </code></pre> <p><strong>Update</strong>: Thanks for the answers. Is volatile needed when I use AtomicInteger?</p>
java
[1]
5,078,284
5,078,285
On Tablets, is internal storage the only option to store images?
<p>On Tablets, is internal storage the only option to store images?</p> <p>I'm writing an app that gets data from a web service, the data is Base64 encoded image. I have to save this image on phones &amp; tablets. On a phone I have the option of storing the image on external storage but if the device is a tablet is internal storage my only option?</p> <p>The tablet im using is a Nexus 7.</p> <p>Thanks for you help.</p>
android
[4]
4,191,698
4,191,699
Balanced Payment integration for iOS
<p>I am trying to do the payment using <a href="https://www.balancedpayments.com/" rel="nofollow">https://www.balancedpayments.com/</a> . They have their iPhone library for this <a href="https://github.com/balanced/balanced-ios" rel="nofollow">https://github.com/balanced/balanced-ios</a> . The problem is that there is not enough documentation on how the Balanced.framework has to be added in the XCode 4.5 project?</p>
iphone
[8]
1,680,669
1,680,670
Declaring variables inside a $.each loop in jQuery
<p>I have a simple jQuery each loop and I wonder if it's possible to declare some variables using it. Something like this:</p> <pre><code>jQuery.each(["var_name1", "var_name2", "var_name3"], function(){ $[this] = this; }); </code></pre> <p>Something like a variable varbiale in php.</p> <p>I know I could store everything inside an object, but it won't help me.</p> <p>Any ideas?</p> <p>EDIT:</p> <pre><code>jQuery.each(["var_name1", "var_name2", "var_name3"], function(key, val){ var $[val] = val; }); alert(var_name1); </code></pre> <p>The Error:</p> <pre><code>SyntaxError: missing ; before statement [Break On This Error] var $[val] = val; </code></pre>
jquery
[5]
3,131,637
3,131,638
I want to perform in place modification to a std::map while iterating over it
<p>I need to know the best way to do the in place modification to the map without taking a local copy of the values modified and then pushing it again into the original map.</p> <p>I have detailed the snippet below that explains the problem: </p> <pre><code>#include &lt;string&gt; #include &lt;map&gt; struct EmployeeKey { std::string name; int amount; int age; }; struct EmployeeDetail { std::string dept; int section; int salary; }; bool compareByNameAge(const std::string&amp; name, const int&amp; age, const EmployeeKey&amp; key ) { return name &gt; key.name &amp;&amp; age &gt; key.age; } typedef std::map&lt;EmployeeKey, EmployeeDetail&gt; EmployeeMap; int main() { EmployeeMap eMap; // insert entries to the map int age = 10; std::string name = "John"; EmployeeMap transformMap; foreach( iter, eMap ) { if ( compareByNameAge(name, age, iter-&gt;first) ) { //**This is what i want to avoid....... // take a copy of the data modified // push it in a new map. EmployeeDetail det = iter-&gt;second; det.salary = 1000; transformMap[iter-&gt;first] = det; } } //** Also, i need to avoid too... // do the cpy of the modified values // from the transform map to the // original map foreach( iter1, transformMap ) eMap[iter1-&gt;first] = iter1-&gt;second; } </code></pre>
c++
[6]
4,740,239
4,740,240
class derived from list
<p>I have a C# class derived from a generic list</p> <pre><code>public class CostCodes : List&lt;CostCode&gt; { public CostCodes() : base() { Add(new CostCode { Description = "DOM0010 Fall Arr", ID = 1599 }); Add(new CostCode { Description = "DOM0020 Acoustics", ID = 1600 }); } </code></pre> <p>when I try to use the Find method on this derived class, no find method appears in intellisense.</p> <pre><code>var codes = new CostCodes(); CostCode costCode = codes.Find(... </code></pre> <p>Figured out that the problem was being caused by the classes being in the test silverlight project. Moved them out, but it would be good to know why it made a difference.</p> <p>-- UPDATE --</p> <p>Cant answer my own question yet, but for those who are interested, this article shows why</p> <p><a href="http://forums.silverlight.net/t/67428.aspx/1" rel="nofollow">http://forums.silverlight.net/t/67428.aspx/1</a></p> <p>Apparently there is no Find method in silverlight projects. You have to use linq and the "first" method instead of find</p> <pre><code>using System.Linq; var costCode = codes.First(cc =&gt; cc.ID == id); </code></pre>
c#
[0]
594,159
594,160
Sending emails digitally signed with S/MIME encryption using phpmailer
<p>I need to know that how can I send an email digitally signed with S/MIME encryption using the phpmailer API. I'm able to send normal email. Please provide me with links or examples of how to do it.</p>
php
[2]
4,757,756
4,757,757
C# Process + Backgroundworker & timer error
<p>I have some code that spawns a process, the file being executed is a Java application and my intent is to read the output from it.</p> <p>The problem is that when I call <code>Start</code>, I am unable to read the output stream after that point. If I test and call <code>Console.Beep</code> after calling <code>Start</code> then the beep will occur - so it is obviously executing these lines.</p> <pre><code>Control.CheckForIllegalCrossThreadCalls = false; Process java = new Process(); java.StartInfo.FileName = "java"; java.StartInfo.Arguments = "-Xms1024M -Xmx1024M -jar craftbukkit-0.0.1-SNAPSHOT.jar nogui"; java.StartInfo.RedirectStandardOutput = true; java.StartInfo.UseShellExecute = false; java.Start(); System.Console.Beep(); System.Console.Write("hejsan"); StreamReader Reader = java.StandardOutput; txtLog.Text = Convert.ToString(System.Console.Read()); broadcast(Convert.ToString(System.Console.Read()), "[Server]", false); </code></pre> <p>Why can't I read from the output stream?</p>
c#
[0]
3,980,036
3,980,037
best way to do this string conversion in Python
<p>I need to convert a string to another which has removed anything before the second word</p> <p>Example from this,</p> <pre><code>string = "xyz anything else" string2 = "xyz anything else" string3 = "xyz anything else" </code></pre> <p>to this,</p> <pre><code>string = "anything else" string2 = "anything else" string3 = "anything else" </code></pre> <p>The way I've done it doesnt please me at all, it isnt pythonic and it's too large. What it would be the best way to do it in Python?</p>
python
[7]
2,069,259
2,069,260
How can i control my Google TV emulator with an another emulator devices
<p>I work in ubuntu 12.0.4 LTS, I want to control my Google TV emulator (provided by android sdk 3.1) with another emulator as a remote.</p> <p>I have already tried to import android library into eclipse and androidLibrary.jar within my apps but it didn't work.</p> <p>hopefully that you can help me . </p>
android
[4]
3,728,952
3,728,953
sdk manager update
<p>I have installed eclipse indiego , added ADT plugins from google repository after that I closed the eclipse and restart again. then no wizard appear to ask for installing a sdk , so I manually install the latest from google developer and give the path in windows-->preference ->android</p> <p>I saw there was no platform and tool-platform in the installed sdk , so I tried to update it from SDK manager,but there is no more choice to update...no additional platform or ...</p> <p>it has some choices: news/update installed but there is nothing new no choose with marking update!! and as you know I cant run a project without platform tools and platforms...</p> <p>so , I get android4 and place it in platforms and also an old platform-tools but the runtime error : crunch command is not known appear as I wanna run a project.</p> <p>so I went back to the first question,how can I update the sdk </p>
android
[4]
5,185,171
5,185,172
How do I set a dictionary size for Activator.CreateInstance?
<p>I want to set the initial size of a dictionary using Activator.CreateInstance, what is the syntax please?</p> <pre><code>var collection = Activator.CreateInstance(someDictionaryType) as IDictionary; </code></pre>
c#
[0]
3,925,021
3,925,022
WindowManager.LayoutParams.TYPE_SYSTEM_ALERT no longer disables home key on Android 4.1
<p>On android Jelly Bean setting the alert dialog window type to WindowManager.LayoutParams.TYPE_SYSTEM_ALERT no longer disables home key. On ICS settings window type to WindowManager.LayoutParams.TYPE_SYSTEM_ALERT would block all key press. Is there any other way to avoid home key and recent app key from dismissing alert dialog on android JB??</p> <p>I need to dismiss the alert dialog only by pressing OK on dialog. Please let me know how to stop home key and recent app key from dismissing the alert dialog</p>
android
[4]
4,337,862
4,337,863
dynamic button event problem
<p>i have some problem.. i have created a dynamic button in a table view. I want to know the method of opening a new view controller when i click the dynamic button in the table view. </p>
iphone
[8]
967,683
967,684
How to convert a const char * to std::string
<p>What is the correct/best/simplest way to convert a c-style string to a std::string.</p> <p>The conversion should accept a max_length, and terminate the string at the first \0 char, if this occur before max_length charter.</p>
c++
[6]
1,262,027
1,262,028
Why isn't this jQuery script working?
<pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function(){ $("tr.reqDet").hide(); $("[title='requestType']").change(function(){ if ($("[title='requestType']").val()!=""){ $("#reqDet").hide(); } else { $("#reqDet").show(); } }); &lt;/script&gt; </code></pre> <p>I cannot get the if statement in the script to work...</p> <p>Details: I'm using SharePoint and it renders a dropdown box w/ attribute title="requestType". When the requestType box is NOT set to the initial value, which is "", I'd like for a control with the class "reqDet" to appear.</p> <hr> <p>Anyways, Thanks everyone. here's the solution that worked for me:</p> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function(){ $("tr.reqDet").hide(); $("select[title='requestType']").change(function(){ $(".reqDet").toggle($(this).val()!== ""); }); }); &lt;/script&gt; </code></pre>
jquery
[5]
2,768,046
2,768,047
& symbol not accepting in jquery ajax
<p>Why &amp; symbol not accepting in jquery ajax?</p>
asp.net
[9]
1,190,021
1,190,022
changing visibility of text android
<p>Hi i have two textViews that i initially set its visibility to gone then animate in and become visible. now i want to make the invisible again but for some reason they're still showing on screen does anyone no why?</p> <p>in my onCreate() i make the view gone</p> <pre><code>register = (TextView)findViewById(R.id.register); register.setVisibility(View.GONE); forgotpassword = (TextView)findViewById(R.id.forgotpw); forgotpassword.setVisibility(View.GONE); </code></pre> <p>then later on i make it visible</p> <pre><code>public void run() { animations(); loginForm.setVisibility(View.VISIBLE); register.setVisibility(View.VISIBLE); forgotpassword.setVisibility(View.VISIBLE); } </code></pre> <p>and then when a user presses a button i want the text views to become invisible so that they retain their layout but they stay visible on screen</p> <pre><code>signInBtn = (Button) findViewById(R.id.signin); signInBtn.setOnClickListener(new View.OnClickListener() { public void onClick(View arg0) { signInProcess(); } }); public void signInProcess() { register.setVisibility(View.INVISIBLE); forgotpassword.setVisibility(View.INVISIBLE); setuploader.setVisibility(View.VISIBLE); </code></pre> <p>}</p>
android
[4]
5,253,810
5,253,811
How to serialize ArrayList
<p>How can I serialize an ArrayList and Save it in a file?</p>
android
[4]
1,503,500
1,503,501
What does static and IOException mean?
<p>I just had a test on java and we had to give the definition of<br> 1) Static:<br> 2) IOExcepion: </p> <p>What I said for static was...a static method is used to define a method as a class method. And I got it wrong so I asked my teacher and he said he wants the actually definition of static not a static method, class or variable just static. Can someone tell me the definition of this and for IOException please Thanks. </p>
java
[1]
3,372,412
3,372,413
Jquery Image Gallery Next Button
<p>Can't seem to get this jquery gallery working. I've been able to get the .galleryImgs click function working, but cant seem to get the #gallery-next click function to work. It's supposed to get the data-src attribute from the next .galleryImgs div and set it in the .galleryImg src. I've tried using addClass and removeClass so it's known which to start from but still wont work. All help appreciated.</p> <pre><code>&lt;img class="galleryImgs" data-src="images/test-image-1.jpg" src="images/test-image-1-s.jpg" /&gt; &lt;img class="galleryImgs" data-src="images/test-image-2.jpg" src="images/test-image-2-s.jpg" /&gt; &lt;img class="galleryImgs" data-src="images/test-image-3.jpg" src="images/test-image-3-s.jpg" /&gt; &lt;img class="galleryImgs" data-src="images/test-image-4.jpg" src="images/test-image-4-s.jpg" /&gt; &lt;img class="galleryImgs" data-src="images/test-image-5.jpg" src="images/test-image-5-s.jpg" /&gt; &lt;img class="galleryImg" src="" /&gt; &lt;div id="gallery-next"&gt;&lt;/div&gt; &lt;script type="text/javascript"&gt; $(function(){ $('.galleryImgs').click(function(){ $('.gallery').show(); $(this).addClass('catherine'); var $galleryImg = $(this).attr("data-src"); $('.galleryImg').fadeIn().attr("src", $galleryImg); }); $('#gallery-next').click(function(){ $('.galleryImgs').hasClass('catherine').removeClass('catherine').next('.galleryImgs').addClass('catherine'); var $galleryImg = $('.galleryImgs').hasClass('catherine').attr("data-src"); $('.galleryImg').attr("src", $galleryImg); }); }); &lt;/script&gt; </code></pre>
jquery
[5]
3,531,749
3,531,750
Timing in javascript vs real time
<p>I have a question: When I do a countdown in JavaScript, and I have a function of the form:</p> <pre><code> &lt;script&gt; var interval; var minutes = 1; var seconds = 5; window.onload = function() { countdown('countdown'); } function countdown(element) { interval = setInterval(function() { var el = document.getElementById(element); if(seconds == 0) { if(minutes == 0) { el.innerHTML = "countdown's over!"; clearInterval(interval); return; } else { minutes--; seconds = 60; } } if(minutes &gt; 0) { var minute_text = minutes + (minutes &gt; 1 ? ' minutes' : ' minute'); } else { var minute_text = ''; } var second_text = seconds &gt; 1 ? 'seconds' : 'second'; el.innerHTML = minute_text + ' ' + seconds + ' ' + second_text + ' remaining'; seconds--; }, 1000); } &lt;/script&gt; </code></pre> <p>The time between each one performance of the function is exactly 1 sec. or there is some delay caused by time due to perform body of function?</p>
javascript
[3]
2,587,801
2,587,802
Detecting when reception returns Android
<p>How do I detect when the reception returns to the phone? is there an intent I can register to get a message when it does? Thanks</p>
android
[4]
4,353,709
4,353,710
Jquery Scrollorama issue
<p>here's my code:</p> <pre><code>&lt;script src="javascripts/jquery.js"&gt;&lt;/script&gt; &lt;script src="javascripts/scrollorama.js"&gt;&lt;/script&gt; &lt;script&gt; $(document).ready(function() { // initialize the plugin, pass in the class selector for the sections of content (blocks) var scrollorama = $.scrollorama({ blocks:'.what' }); // assign function to add behavior for onBlockChange event scrollorama.onBlockChange(function() { var i = scrollorama.blockIndex; console.log('changed'); }); scrollorama.animate('#dollar',{ delay: 400, duration: 300, property:'left', start:-1400, end:0 }); }); </code></pre> <p>And console returns with this error:</p> <pre><code>Uncaught TypeError: Object function (e,t){return new y.fn.init(e,t,n)} has no method 'scrollorama' </code></pre> <p>What could be possibly wrong? Thanks for any tips.</p>
jquery
[5]
1,016,087
1,016,088
how to read blob from sql server using c#?
<p>I have a console application using C# where I want to read the blob stored in SQL Server and write it to windows file system at a specified path.</p> <p>How do I convert a blob to a image of pdf using C# and write it to a file system?</p>
c#
[0]
4,495,326
4,495,327
C# Downcasting Lists to IList "special tactics"
<p>So I'm working at a company and I'm relatively new here but I've come across something very strange in some production code which I'm told are written by someone much more knowledgable in C# than myself who "does things a special way". So I'm trying to think of reasons to do what I'm about to explain, giving the benefit of the doubt but I can't come up with anything.</p> <p><code>IList&lt;Facility&gt; Facilities = new List&lt;Facility&gt;();</code></p> <p>The above line is at the core of the problem... the other oddities all throughout the code come from being unable to use interfaces for some things and therefore the data has to be copied back out into a List before using them (for example exporting via webservice, does not allow using an interface, must be an implementation of IList)</p> <p>Now I understand interfaces are wonderful in the sense that you can write methods which expect the methods presribed in the interface to exist on the implementation which is being passed to your method but...</p> <p>Can someone please help me out here... can anyone think of a reason you'd immediately downcast a List back to its interface in the data layer of an application?</p> <p>Also just to make it clear... these lists are not used for interchangeable data types either, this occurs at the point where the List is defined and stored, and there is an IList per datatype which is stored.</p> <p>Thanks!</p>
c#
[0]
4,158,283
4,158,284
Why span dissapears on mouseenter?
<pre><code>&lt;DIV id=gallery2&gt; &lt;DIV class=center_content&gt; &lt;A id=example2 class=photo-link title=567 href="http://www.hdwallpapersarena.com/wp-content/uploads/2012/06/Desktop-wallpaper-Free-honey-bee1.jpg" rel=group1 smoothbox?&gt; &lt;IMG id=mygal class=mygalclass src="http://www.hdwallpapersarena.com/wp-content/uploads/2012/06/Desktop-wallpaper-Free-honey-bee1.jpg" width=132 height=137&gt; &lt;/A&gt; &lt;/DIV&gt; &lt;/DIV&gt; </code></pre> <p>Hovering on the bee image shows me a <code>span</code> with links, but when I go and select the <code>span</code> it disappears, I guess it's because of the <code>mouseleave</code> event of the image. </p> <p>here's a demo <a href="http://jsfiddle.net/sbYG4/13/" rel="nofollow">http://jsfiddle.net/sbYG4/13/</a></p> <p>How can I tie the <code>Div</code>, <code>Image</code> and <code>Span</code> to the same <code>onmouseenter</code> and <code>mouseleave</code>?</p>
jquery
[5]
189,310
189,311
Can I add folders to Drawables and cycle files in them?
<p>Wanted to ask how I can add my own folders with drawables to resources? And how could I later cycle through all files in a specific folder?</p> <p>Thanks!</p>
android
[4]
254,952
254,953
jQuery check childNode class
<p>I'm trying to figure out how to check the class of a childNode. I currently have a list like this:</p> <pre><code>&lt;li&gt; &lt;a href="#"&gt;Link&lt;/a&gt; &lt;ul class="children"&gt; &lt;li class="current"&gt;&lt;/li&gt; &lt;li&gt;&lt;/li&gt; &lt;li&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; </code></pre> <p>Previously, an additional 'active' class was being applied to a ul which contained a li.current, and I had this jQuery script which was doing the job of marking the parent li as active as well as the sibling a:</p> <pre><code>jQuery("ul.active").siblings('a').addClass('current').parent().addClass('current'); </code></pre> <p>but the 'active' class is not longer being applied, so I need to check the children of any ul.children to see if any are li.current. I'm just not sure how to go about it ... </p>
jquery
[5]
5,350,483
5,350,484
how i can resolve this open cv sample native camera?
<p>I got this error when I run <code>open cv sdk 2.4.2</code> on my devices:</p> <pre><code> 09-19 04:41:27.880: E/dalvikvm(1188): Could not find class 'org.opencv.samples.tutorial2.Sample2NativeCamera$1', referenced from method org.opencv.samples.tutorial2.Sample2NativeCamera.&lt;init&gt; </code></pre> <p>The project call "add camera" didn't error on my devices. How can I solve this problem?</p>
android
[4]
4,455,994
4,455,995
Vibrate in dynamic pattern
<p>I'm coming from Actionscript 3 and new to Java. I'm trying to make a vibrate pattern half of which is fixed and half of which is dynamic. For eg:</p> <pre><code>long[] vibratePattern = {100,100,100,100} //fixed pattern if(some_condition) vibratePattern.append(400); if(some_condition) vibratePattern.append(200); if(some_condition) vibratePattern.append(100); </code></pre> <p>But long[] <a href="http://stackoverflow.com/questions/5144549/append-values-dynamically-into-an-long-array">doesn't</a> have any append or add method.</p> <p>I tied creating ArrayList but the method <a href="http://developer.android.com/reference/android/os/Vibrator.html#vibrate%28long%5B%5D,%20int%29" rel="nofollow">Vibrator.vibrate</a> takes long[] as parameter.</p> <p>So my question is how can I make long[] array with half fixed item and half dynamic item and pass it to Vibrator.vibrate method. Can I create some other list and pass it as long[] to the method?</p>
android
[4]
3,772,541
3,772,542
How to get title attribute for each a href and put as span?
<p>Hi I am trying to get the title attribute of each a href in jQuery and put it as a span and have done something like this:</p> <pre><code>$('.menu li').each(function(){ var title = $('.menu li a').attr("title"); $(".menu li a span").text(title); }); </code></pre> <p>Each link has a different title attribute added too it but its applying the first title attribute to every span, am I missing something? </p> <p>thanks</p>
jquery
[5]
5,552,445
5,552,446
Python list lookup with partial match
<p>For the following list:</p> <pre><code>test_list = ['one', 'two','threefour'] </code></pre> <p>How would I find out if an item starts with 'three' or ends with 'four' ?</p> <p>For example, instead of testing membership like this:</p> <p><code>two in test_list</code></p> <p>I want to test it like this:</p> <p><code>startswith('three') in test_list</code>.</p> <p>How would I accomplish this?</p>
python
[7]
1,013,847
1,013,848
unclosed string literal error at compile time because it contains double quotes and pre tags of HTML
<p>In my program, there is a string that contains double quotes and less than and greater than symbols. Here is a sample String:</p> <pre><code>String s2="div class=\"codeblock\"&gt;&lt;pre name=\"code\" class=\"java\" "; </code></pre> <p>Can anyone help me?</p>
java
[1]
4,367,147
4,367,148
Add class to an element
<p>I try to write these code to make grid view through CSS:( jsbin )</p> <pre><code> var tables = document.getElementsByClassName('tableData'); var rows = tables[0].getElementsByTagName('tr'); for(var i=1; i&lt;rows.length; i +=2) { alert(rows[i]); rows[i].className = "alt"; } </code></pre> <p>This only works with the tr elements has <code>class=""</code> . But if I want to add class to tr . I've tried Core.addClass but it doesn't work .</p> <p>​</p>
javascript
[3]
3,513,641
3,513,642
Changing directory using php passthru()
<p>I want to change the working directory using passthru() method and commandline ..</p> <p>This is the php script</p> <pre><code>&lt;?php passthru("chdir C:/Documents and Settings/svn"); print passthru("dir"); ?&gt; </code></pre> <p>However, it is not changing the working directory to C:/Documents and Settings/svn.. It is outputting the files from the current directory .. How can i fix this ?</p>
php
[2]
3,824,199
3,824,200
<asp:File upload control is not visible what ever I do
<p>Some thing weird is happening. I created a simple form and Added an <code>&lt;asp:file upload&gt;</code> control to the page. When I run it, I am not able to see the control at all.</p> <p>When I click on the place where I added it is letting me upload a file. I even added visible="true" still not able to see the control.</p> <p>When I click on the page source I see something suspicious that may be the reason for the forms behavior.</p> <pre><code>&lt;div class="aspNetHidden"&gt; &lt;input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWAwKLs+6YAwLCi9reAwKgt7D9ClxerRe75aEgGdz92Sy7arcrPod6Ll9TW47l0BpDRTNL" /&gt; </code></pre> <p>Did you ever experience this? Can youy tell me what am I doing wrong?</p> <p>Here is the code</p> <pre><code>&lt;div&gt; &lt;asp:FileUpload ID="filResume" class="file" runat="server" width="600" size="81" /&gt; &lt;/div&gt; &lt;asp:RequiredFieldValidator runat="server" id="reqFilResume" ControlToValidate="filResume" Display="Dynamic" cssClass="validator_right"&gt;*Required &lt;/asp:RequiredFieldValidator&gt; &lt;asp:RegularExpressionValidator Display="Dynamic" id="fileUploadValidator" runat="server" ErrorMessage="*Resume must be a .pdf, .doc, or .docx file!" ValidationExpression="^.+\.(pdf|PDF|doc|DOC|docx|DOCX)$" ControlToValidate="filResume" cssClass="validator_right"&gt; &lt;/asp:RegularExpressionValidator&gt; </code></pre>
asp.net
[9]
5,046,031
5,046,032
Loading random form into jQuery Tools overlay
<p>I asked how to load a random form in another thread and got great answers. Here is what I got and verified to work</p> <pre><code>$(function() { $("a.random")click.(function){ $(".test_form").hide(); var formNumber = Math.floor(Math.random() * 4);//will equal a number between 0 and 3 $("#form" + formNumber).show(); }); }); </code></pre> <p>I need to apply this somehow to a jQuery Tools overlay that is being triggered as such </p> <pre><code>&lt;a href="Forms/SupportFormTest.php" rel="#overlayForm"&gt; </code></pre> <p>and modify the href somehow to include the a reference to the function. would simply removing the href and using a class work? But then I would somehow have to add a path to the forms they are in another directory "/Forms". Help is much appreciated, the flowplayer.org forms are less than helpful</p>
jquery
[5]
3,929,639
3,929,640
Would like to concantenate list of fields one of which is a URL link
<pre><code>$list[] = '&lt;li&gt;&lt;a href="' . $row-&gt;tr_survey_link . '"&gt; ' . $row-&gt;Survey_Subject . '&lt;/a&gt;&lt;/li&gt;'; </code></pre> <p>How would I add a field after the Href each time I try I get nothing showing in list... </p> <p>want to add $row->Evaluator_Type before or after link.... but it just does not seem to work</p>
php
[2]
5,510,290
5,510,291
String or binary data would be truncated. The statement has been terminated
<p>In my web application,i am storing password in the database using encryption. the password field's datatype is nvarchar(max). Even i enter the 10 character password e.g. '8427484274' then also i am getting the error. I came to know by searching this is the error we get when we try to store the data more then the datatype's capacity..one thing i want to make clear is that i have '=' symbol in my encrypted string...is there any issue with datatype?if so what can be the biggest datatype then varchar(8000),i have tried that also and still getting the error.how to resolve this?</p>
asp.net
[9]
1,806,929
1,806,930
in python , how to make two lists contianing the same elements not equal with each other?
<p>say we got two lists: </p> <pre><code>a = [1, 2, 3] b = [1, 2, 3] </code></pre> <p>then all the following expressions will return True:</p> <pre><code>a == b # True a == list(b) # True a == list(tuple(b)) # True a == copy.deepcopy(b) # still True </code></pre> <p>But i do want a "False" returned, because when a and b hold different meanings, they should be two different objects.</p> <p>so is there any way to make them NOT equal with each other but still can be manipulated as a list?</p>
python
[7]
5,265,134
5,265,135
I have a requirement that is converting a string (2011/05/02 02:55:20 PM) to date
<p>I have a requirement that is converting a string (2011/05/02 02:55:20 PM) to date</p>
java
[1]
1,137,040
1,137,041
Using JavaScript to launch window behind browser for users agreeing to survey
<p>I am asking a small percentage of users on a site if they would take a short survey. If they click 'yes' I would like to close the little pop-up window i have open that is asking them, and launch a new window in the background that comes to the forefront once they leave my domain - or close their browser.</p> <p>Right now I am using a form:</p> <pre><code> &lt;form&gt; &lt;input type="button" value="Yes" name="Yes" onclick="javascript:openSurvey();"&gt; &lt;input type="button" value="No Thanks" name="No" onclick="javascript:closeSurvey();"&gt; &lt;/form&gt; </code></pre> <p>I'm having trouble with this though. I think I can launch the new window OK, but I can't figure out how to close the other window and put the new window in the background. Any tips?</p>
javascript
[3]
3,462,601
3,462,602
Programmatically change the width of the Button in android
<p>How to change the Width of a button programmatically. I am able to change the height but the width does not change. Following is my code snippet</p> <pre><code>private void createButton(final String label) { Button button = new Button(this); button.setText(label); button.setWidth(10); button.setHeight(100); button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { } }); mMenuContainer.addView(button, mMenuItemLayoutParamters); } </code></pre> <p>But the width of the button occupies the width of the screen.</p>
android
[4]
3,709,266
3,709,267
Iphone Movement in particular direction with particular speed
<p>How can i find when iphone moving particular direction (i.e X axis) with particular speed using its UIAcceleration values?</p> <p>Can anyone help me ?</p> <p>Thanks in advance.........</p>
iphone
[8]
1,926,090
1,926,091
Why are the MDC prototype functions written this way?
<p>In MDC there are plenty of code snippets that meant to implement support for new ECMAScript standards in browsers that don't support them, such as the <code>Array.prototype.map</code> function:</p> <pre><code>if (!Array.prototype.map) { Array.prototype.map = function(fun /*, thisp */) { "use strict"; if (this === void 0 || this === null) throw new TypeError(); var t = Object(this); var len = t.length &gt;&gt;&gt; 0; if (typeof fun !== "function") throw new TypeError(); var res = new Array(len); var thisp = arguments[1]; for (var i = 0; i &lt; len; i++) { if (i in t) res[i] = fun.call(thisp, t[i], i, t); } return res; }; } </code></pre> <p>What's the benefit (if there's any) of using this function rather than</p> <pre><code>function(fun, thisp) { // same code, just without the "var thisp = arguments[1];" line: "use strict"; if (this === void 0 || this === null) throw new TypeError(); var t = Object(this); var len = t.length &gt;&gt;&gt; 0; if (typeof fun !== "function") throw new TypeError(); var res = new Array(len); for (var i = 0; i &lt; len; i++) { if (i in t) res[i] = fun.call(thisp, t[i], i, t); } return res; } </code></pre> <p>, <code>var t = Object(this);</code> rather than <code>var t = this;</code> and <code>var len = t.length &gt;&gt;&gt; 0;</code> rather than <code>var len = t.length;</code>?</p>
javascript
[3]
2,639,968
2,639,969
CSV file to flat array with materialized path
<p>I have CSV file which contains a list of files and directories:</p> <pre><code>Depth;Directory; 0;bin 1;basename 1;bash 1;cat 1;cgclassify 1;cgcreate 0;etc 1;aliases 1;audit 2;auditd.conf 2;audit.rules 0;home .... </code></pre> <p>Each line depends on the above one (for the depth param)</p> <p>I would like to create an array like this one in order to store it into my <a href="http://www.mongodb.org/display/DOCS/Trees+in+MongoDB#TreesinMongoDB-MaterializedPaths%28FullPathinEachNode%29" rel="nofollow">MongoDB collection with Materialized Paths</a></p> <pre><code>$directories = array( array('_id' =&gt; null, 'name' =&gt; "auditd.conf", 'path' =&gt; "etc,audit,auditd.conf"), array(....) ); </code></pre> <p>I don't know how to process... Any ideas?</p> <p><strong>Edit 1</strong>: I'm not really working with directories - it's an example, so I cannot use FileSystems functions or FileIterators.</p> <p><strong>Edit 2</strong>: From this CSV file, I'm able to create a JSON nested array:</p> <pre><code>function nestedarray($row){ list($id, $depth, $cmd) = $row; $arr = &amp;$tree_map; while($depth--) { end($arr ); $arr = &amp;$arr [key($arr )]; } $arr [$cmd] = null; } </code></pre> <p>But i'm not sure it's the best way to proceed...</p>
php
[2]
3,161,638
3,161,639
Can I have a form on index.php and process it with index.php
<p>Is this possible? I have looked online and cannot seem to find an answer.</p>
php
[2]
57,213
57,214
Create bitmap to compare two images by pixel
<p>I am trying to compare two images by pixel. I have searched on Google about bitmap but I did not clear with it.</p> <p>My code is showing error <code>Parameter is not valid</code>.</p> <p>I have try this;</p> <p>var a = new Bitmap(imageurl);</p> <p>but it does not work.</p> <p>I am also refer this site for image comparison:</p> <p><a href="http://www.c-sharpcorner.com/uploadfile/prathore/image-comparison-using-C-Sharp/" rel="nofollow">http://www.c-sharpcorner.com/uploadfile/prathore/image-comparison-using-C-Sharp/</a></p> <p>What I have tried:</p> <p>but showing error on this line <code>parameter is not valid</code>.</p> <pre><code>var img1 = new Bitmap(fileone); var img2 = new Bitmap(filetwo); </code></pre> <p>I have store path in this two variable like this,</p> <pre><code>fileone=C:\image\a.jpg: filetwo=c:\image\b.jpg; var img1 = new Bitmap(fileone); var img2 = new Bitmap(filetwo); if (img1.Width == img2.Width &amp;&amp; img1.Height == img2.Height) { for (int i = 0; i &lt; img1.Width; i++) { for (int j = 0; j &lt; img1.Height; j++) { img1_ref = img1.GetPixel(i, j).ToString(); img2_ref = img2.GetPixel(i, j).ToString(); if (img1_ref != img2_ref) { count2++; flag = false; break; } count1++; } // progressBar1.Value++; } if (flag == false) Response.Write("Sorry, Images are not same , " + count2 + " wrong pixels found"); else Response.Write(" Images are same , " + count1 + " same pixels found and " + count2 + " wrong pixels found"); } else Response.Write("can not compare this images"); this.Dispose(); </code></pre>
c#
[0]
217,390
217,391
Using a for loop to count size or List<string>?
<p>I have a for loop in which i test for the size of a list.</p> <pre><code>for(int i = 0; i&lt; thumbLinks.size(); i++) { Log.e("URL" + i, thumbLinks.get(i)); url0 = thumbLinks.get(i); url1 = thumbLinks.get(i); //Fix index out of bounds exception url2 = thumbLinks.get(i); } </code></pre> <p>When i is added each time as you can see i am asking for i 3 times to get 3 urls. Since i am unsure about how many URL's i will have. I use i to increase. The correct output i want is for </p> <pre><code> url0 = thumbLinks.get(i);// which is support to be equivalent to 1 url1 = thunkLinks.get(i);//which is suppose to be equivalent to 2 </code></pre> <p>and so on..</p> <p>But my code doesnt do this...</p> <p>It just adds 1 each time to each url. How can i fix this ?</p>
java
[1]
3,764,145
3,764,146
How to get mp3 file duration Http streamed over Android MediaPlayer
<p>I am making a media player application in which i have a Mp3 file URL that i need to http stream down over Android MediaPlayer.</p> <p>Now My Streaming is working very fine . Song is getting downloaded and Played Successfully. But i need to show the Downloading and Song Progress over a ProgressBar/SeekBar. As soon i got my initial data buffer filled with some song data my streamer plays the song.</p> <p>But i need to know the total duration of song so that i can set the Progress Bar accordingly. As soon my Media Player starts playing the song. I call</p> <p>mediaPlayer.getDuration() for getting the file duration .. But it is not giving me the right data untill the whole song get downloaded....</p> <p>This is bad . as it seems getDuration() Method of MediaPlayer is showing the duration on the basis of downloaded content instead of checking the header of Mp3 file.....</p> <p>I am following the tutorial for Http streaming audio song from the following Link</p> <p><a href="http://blog.pocketjourney.com/2008/04/04/tutorial-custom-media-streaming-for-androids-mediaplayer/" rel="nofollow">http://blog.pocketjourney.com/2008/04/04/tutorial-custom-media-streaming-for-androids-mediaplayer/</a></p> <p>Any Help would be appreciated. Thanks</p>
android
[4]
5,127,580
5,127,581
How to prevent multiple object instantiations of a certain class
<pre><code>MyInterface intf = (MyInterface) Class.forName(className).newInstance(); </code></pre> <p>I have a certain piece of code which will create new interfaces on demand using the above call and invoke a certain method. All of the implementation classes usually contain lots of <code>final static</code> variables and static initialization code which I would like to fire only once in its lifetime.</p> <p>But since I am using the newInstance() call, I am under the impression that the old object gets GCed and the class is initialized again and hence all the static variables.</p> <p>In order to avoid this, I would like to put this in a cache, so that these classes are not re-constructed again and hence would be initialized once during its lifetime. (Note: My interfaces are thread-safe).</p> <p>Should I just put this in a <code>Hashtable</code> and just look it up or is there a better way to handle the cache?</p>
java
[1]
5,344,797
5,344,798
Deleted nib still displayed when controller is pushed
<p>I have an application with a UINavcontroller under a tab bar controller. To create the navigation model I want, I push a container UIView object onto the stack to manage additional views(Thanks Frank). When I created the container class, an associated nib file was created along with it. I at first used that nib file, but it turned out it was better not to. So I deleted the nib (and selected 'also move to trash'). The problem is that it still shows up when I push its view controller onto the stack. I have tried emptying the cache in xcode and restarting xcode. What am I missing?</p>
iphone
[8]
1,762,874
1,762,875
input file cannot be found
<p>I am just messing around with reading input files with java until I got stumped at the most basic of steps... finding the input file!</p> <p>The input.txt file is in the same directory as my class file that is calling it yet eclipse still gives me an error that it cant be found:</p> <p>"Exception in thread "main" java.lang.Error: Unresolved compilation problem: Unhandled exception type FileNotFoundException"</p> <p>My code:</p> <pre><code>package pa; import java.util.Scanner; public class Project { public static void main(String[] args) { java.io.File file = new java.io.File("input.txt"); System.out.println(file.getAbsolutePath()); Scanner input = new Scanner(file); } } </code></pre> <p>input.txt is in the same package, same folder and everything. I'm confused :(</p>
java
[1]
3,359,913
3,359,914
Improving performance of ifstream in c++
<p>I apologize if this question is a bit vague or just plain stupid, I am still very much a novice.</p> <p>I need to extract information from a web log file in c++. The string manipulations are relatively, accessing the data in a timely fashion isn't. What I am doing currently</p> <p><code>string str;</code></p> <p><code>ifstream fh("testlog.log",ios::in);</code></p> <p><code>while (getline(fh,str));</code></p> <p>From here I get the useful data from the string. This works fine for a log file with 100 entries, but takes forever on a log file with million+ entries. Any help would greatly be appreciated</p>
c++
[6]
979,629
979,630
Time Calculation
<p>I am on a time calculation to calculate a delay time for a train Schedule time : t1 Arrival time : t2</p> <pre><code>function tomdiff(t1,t2) { var t1 = hour2mins(t1); var t2=hour2mins(t2); var ret = mins2hour(parseInt(t2-t1)); if(t2&lt;t1) {ret=mins2hour(parseInt(parseInt(t2+1440)-t1));} return ret; } //Calculate on Key up $("input.[rel=time1]").keyup(function (b){ $("#delaytime").val(tomdiff($("#schedule").val(),$("#arrival").val())); }); </code></pre> <p>This is working great but what if the train arrive earlier!</p> <p>Can someone advise me?</p>
jquery
[5]
5,503,156
5,503,157
Python command line SETUP for ABSOLUTE BEGINNER with Python
<p>I'm "new school" meaning that i've never really used the command prompt(they didn't teach us anything but IDE's in school). I would like to setup Python using Notepad++ for the editor, and winpdb as my debugger.</p> <p>I want stuff to work really easy from the cmd prompt but it is not.</p> <p>This is what I put in my System Environment: C:\PYTHON27;C:\PYTHON27\DLLs;C:\PYTHON27\LIB;C:\PYTHON27\LIB\LIB-TK;C:\PYTHON27\LIB\SITE-PACKAGES;</p> <p>This is what i want to have happen (but it doesn't work, doesn't load python or the script): python myscript.py Then it should run the interpreter. I'd like it to find my script file wherever it may be.</p> <p>Can someone baby-step me through this command line setup (the docs expect the user to know how to fluently use the cmd prompt)</p> <p>I just don't want to have to manually put in path every single time I want to do something</p> <p>Also I have Console2, I would rather use this than the standard cmd. How do i get it to have the same functionality that i'm looking for?</p>
python
[7]
2,597,947
2,597,948
Scale textsizes for different screen sizes
<p>I have some layouts and I want to adjust my textsize to the screen size. I used sp for all my sizes, but when I switch to my tablet my text still looks to small. </p> <p>Is there a common scale formula or something to simply do this ?</p>
android
[4]
115,955
115,956
Get the number of unread mails on an Android Device
<p>Is there a way to ask the mail programms on an Android Device how many unread mails they have?</p>
android
[4]
2,447,977
2,447,978
Understand Reference and Dereferencing Operators?
<p>Can someone please help me understand Reference and Dereference Operators?</p> <p>Here is what I read/understand so far:</p> <pre><code> int myNum = 30; int a = &amp;myNum; // a equals the address where myNum is storing 30, int *a = &amp;myNum; // *a equals the value of myNum. </code></pre> <p>When I saw the code below I was confused:</p> <pre><code> void myFunc(int &amp;c) // Don't understand this. shouldn't this be int *c? { c += 10; cout&lt;&lt; c; } int main() { int myNum = 30; myFunc(myNum); cout&lt;&lt; myNum ; } </code></pre> <p><code>int &amp;c</code> has the address to what's being passed in right? It's not the value of what's being passed in.</p> <p>So when I do <code>c+=10</code> it's going to add 10 to the memory address and not the value 30. Is that correct?</p> <p>BUT... when I run this...of course with all the correct includes and stuff...it works. it prints 40.</p>
c++
[6]
2,052,061
2,052,062
Java, opinion on using Object class?
<p>I'm wondering what the general opinion is on using Java's Object class for something like this:</p> <pre><code>private Car myCar; private String myCarBrand; public void set(String variableToSet, Object valueToSet){ if(myCarBrand.equals("AUDI")){ if(varibleToSet.equals("COLOR")) (Audi myCar).setColor((Color) valueToSet); ... } ... } </code></pre> <p>Somehow I have the feeling that I shouldn't be using the Object class. However my reason for doing so is that not all cars have the same setter functions, now I could split this into multiple setters with the same name, but with different types of <code>valueToSet</code>, that however requires a lot more code, especially if my <code>valueToSet</code>'s have largely different types.</p> <p>Thanks</p> <p><strong>ERRATA</strong></p> <ul> <li><p><code>Audi extends Car</code></p></li> <li><p>setColor is supposed to represent a class that is not applicable to all cars, something like <code>turnOnBackSeatDiscoLights</code> might have been better suited. </p></li> </ul>
java
[1]
332,194
332,195
Callback routine in Android
<p>I ran into a piece of Android code. I don't quite understand the purpose of the callback because it's empty. </p> <p>In Animation.java</p> <pre><code>private AnimationCallback callback = null; public Animation(final AnimationCallback animationCallBack) { this(); callback = animationCallBack; } public void stop() { if (callback != null) { callback.onAnimationFinished(this); } active = false; } public interface AnimationCallback { void onAnimationFinished(final Animation animation); } </code></pre> <p>but in <code>AnimationCallback</code> there's only</p> <pre><code>public interface AnimationCallback { void onAnimationFinished(final Animation animation); } </code></pre> <p>I guess my question is what does <code>callback.onAnimationFinished(this)</code> do? There doesn't seem to have anything inside the routine.</p>
android
[4]
1,329,730
1,329,731
How to share a variable across classes in Java, I tried static didn't work
<p>class Testclass1 has a variable, there is some execution which will change value of variable. Now in same package there is class Testclass2 . How will I access updated value(updated by Testclass1) of variable in Testclass2. tried this didn't work </p> <p>Note: Testclass1 and Testclass2 are two separate files in same package, I tried to run class1 first in eclipse and then class2. But class2 printed 0;</p> <pre><code>public class Testclass1 { public static int value; public static void main(String[]args) { Testclass1.value=9; System.out.println(value); } } ---------------- public class Testclass2 { public static void main(String[]args) { System.out.println(Testclass1.value); } } </code></pre>
java
[1]
1,645,746
1,645,747
Array in gridview
<p>I have a string array data[].I need to bind this string array as datasource in gridview. I have values in data array. I write the code gridview_forecast.DataSource = data; gridview_forecast.DataBind(); I got an <strong>error</strong> as "A data item was not found in the container. The container must either implement IDataItemContainer, or have a property named DataItem."</p>
asp.net
[9]
3,612,365
3,612,366
onchange event and auto grow textbox
<p>i have made auto grow textarea.it's working fine but when copying and pasting using right click it's not working properly.if i use onchange event in this situation it won't work either because to fire this event we need press enter or tab. please help me to solve this problem</p>
javascript
[3]
4,025,209
4,025,210
How to add tabhost control on each page of our android application?
<p>I want to display and handle events of tabhost control on each page of android application without creating it again and again, as in asp.net we have masterpage concept on which we can place our common controls, is there anything in android, so that i can place tabcontrol there.</p>
android
[4]
3,309,966
3,309,967
fputcsv and checkboxes
<p>I trying simplify my form submit by using <code>fputcsv</code>. my question is how do I process checkboxes? also since i'll be appending do I need to change the <code>"w"</code> to <code>"a"</code>?</p> <pre><code>if(isset($_POST['submit'])) { $data = implode(',', $_POST); if( $fp = fopen('form_data.csv', 'w') ){ fputcsv($fp, $data); } fclose($fp); } </code></pre>
php
[2]
4,604,341
4,604,342
Creating IPA file for iPad testing
<p>I need to give an IPA file for testing in my clients i Pad. I have given him 3 IPA files so far and all of them crashed when installing. The client says when clicking on the app icon a black screen appears and closes immediately taking him back to the home screen. How do i create an IPA file. I need clear steps from creating Provisioning profile, creating apple id,setting the Bundle identifier etc.I have gone thr' many forums and links but all of them seem to confuse me. I use xcode 4.2.Thanks in advance.</p>
iphone
[8]
1,827,666
1,827,667
How to append before last li in dropdown list
<p>I am using the following form builder (<a href="http://dontlink.me/formbuilder/" rel="nofollow">http://dontlink.me/formbuilder/</a>) and making lots of changes to it to work the way I want.</p> <p>One of the things I want it to do is when you add a new form field, I want that form field to be placed at the bottom of the list... At the moment they are placed at the top.</p> <p>This is the code that adds the new li to the list... I've simplified it down to the part that actually does the adding...</p> <pre><code>var result = '&lt;li&gt;The new form field code goes here....&lt;/li&gt;'; var into = $("#form_builder_panel ol"); $(into).prepend(result); </code></pre> <p>For some reason by default they add an "li" tag into the code and give it a class of 'last-child'.</p> <pre><code>&lt;div id="form_builder_panel"&gt; &lt;form method="post" action="preview.php" class="fancy"&gt; &lt;fieldset class='sml'&gt; &lt;legend&gt;Built Form&lt;/legend&gt; &lt;ol&gt; &lt;li class="last-child"&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/fieldset&gt; </code></pre> <p>Now I tried changing that third line of code to the following:</p> <pre><code>$(into).append(result); </code></pre> <p>But that then puts the 'last-child' li at the top and the script stops working...</p> <p>So my question is, how do I make it so that it appends a new li to the list but adds it above the 'last-child' li?</p> <p>Hopefully I am making sense :)</p>
jquery
[5]
4,741,864
4,741,865
jQuery Cookie path/subdirectory issue
<p>I hope someone might be able to help me out. I have an jQuery animated quicklaunch in which I "remember" the open/closed states through use of jQuery cookies. This works well, with the exception of certain instances.</p> <p>Basically works as planned on every /path1/SitePages/ wiki page as necessary, however</p> <p>a) when I navigate to a library link in the same site, /path1/Shared Documents/Forms/ or to /path1/Forms/Forms/AllItems.aspx for instance, the cookies for those sub directories kick in which can be in different open/closed states, messing up the user experience.</p> <p>I just want one set of cookies to determine the open/closed states of my sharepoint site, not competing sub directory cookies.. how is this possible? below is the code I use to apply the cookie..</p> <pre><code> $("#s4-leftpanel-content ul.root&gt;li.static&gt;a.menu-item").click(function(){ var obj = $(this); var parObj = obj.parent(); var element = $("ul", parObj); var show = $(element).is(":visible")?true:false; if(!show) { $(element).addClass("selected"); $(element).show('fast'); $(element).prev('a').addClass('active'); $.cookie($(this).text(), 'expanded'); } else { $(element).removeClass("selected"); $(element).hide('fast'); $(element).prev('a').removeClass('active'); $.cookie($(this).text(), 'collapsed'); } return false; </code></pre>
jquery
[5]
17,564
17,565
Get Current Time of CalendarEntry of Google Calendar API
<p>I was wondering, is there anyway to get the current time of a CalendarEntry, of Google Calendar API.</p> <p>I try to use the following hack :</p> <pre><code> try { if (calendarEntry.getSummary().getPlainText().equalsIgnoreCase("XXX")) { calendarEntry.setSummary(new PlainTextConstruct("YYY")); } else { calendarEntry.setSummary(new PlainTextConstruct("XXX")); } calendarEntry = calendarEntry.update(); } catch (IOException ex) { Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); } catch (ServiceException ex) { Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); } // According to documentation, getUpdated shall returned CalendarEntry last // update time. // Hopefully by explicitly modify the state of calendar, // getUpdated will return latest time. // Unfortunately, I find out the result is not always up-to-date. It will // return pass time still. System.out.println("Calendar Entry = " + calendarEntry.getUpdated()); </code></pre> <p>Getting NTP time from public time server is another option. However, I found out this doesn't meet my requirement, as it is quite time wasting, to make an extra query to another time server, instead of directly retrieve the information from Google itself.</p>
java
[1]
3,481,490
3,481,491
jquery code to change number to other with fading like digg
<p>i have this :</p> <pre><code>&lt;script&gt;var newnumber="680";&lt;/script&gt; &lt;div id="number-area"&gt;458&lt;div&gt; &lt;button onclick="changeit()"&gt; </code></pre> <p>i want a jquery code to change the content of the div "number-area" to the variable "newnumber".</p> <p>and that's with a fad in &amp; fad out like when you click "digg" button on digg website.</p> <p>Thanks</p>
jquery
[5]
1,557,402
1,557,403
Search for elements that matches a pattern in PHP
<p>I have a string like <code>sub_category-21,cross_category-23,sub_category-33,sub_category-93,cross_category-69</code>.</p> <p>I want to obtain the numbers for sub_category and the ones for cross category.</p> <p>What I've done since now is seperate it in an array:</p> <pre><code>$categories = explode(",", $_POST["categories"]); $sub_categories = array(); $cross_categories = array(); foreach($categories as $category) { } </code></pre> <p>How I can do it?</p> <p>Thank you in advance!</p>
php
[2]
5,947,290
5,947,291
Android: What is a difference between 'orientation' and 'screenLayout'?
<p>There are 2 different constants that have same description (<a href="http://developer.android.com/intl/de/reference/android/R.attr.html#configChanges" rel="nofollow">http://developer.android.com/intl/de/reference/android/R.attr.html#configChanges</a>)</p> <pre><code>orientation 0x0080 The screen orientation has changed, that is the user has rotated the device. screenLayout 0x0100 The screen orientation has changed, that is the user has rotated the device. </code></pre> <p>Many sources suggest to specify:</p> <pre><code>android:configChanges="keyboardHidden|orientation" </code></pre> <p>But should not it be:</p> <pre><code>android:configChanges="keyboardHidden|orientation|screenLayout" </code></pre>
android
[4]
630,911
630,912
Patterns / Design
<p>I do C# programming as a hobby mostly. This means I write certain amounts of code but lack the insight of other programmers, senior or not to provide insight into alternative, more useful or cleaner code patterns or habits. Even design of a library itself.</p> <p>How do others deal with this situation to get decent code review? Some site? Making it open source? Some other manner?</p>
c#
[0]
1,247,484
1,247,485
Android - keytool XML signing/verification
<p>Is it necessary to create both (private and public keys) via keytool utility? Is the private key created by "-protected" added when exporting keystore by keytool? If I have now private and public keys, how to make initial signing process and verification of some, e.g. external XML document?</p> <p>Thanks</p>
android
[4]
2,703,013
2,703,014
Android: Animated gif
<p>I've got an animated gif which is a loading bar. The image displays but there is no animation, how would I get it to animate?</p>
android
[4]
4,621,953
4,621,954
Is there a way to use out parameter as an optional parameter in C#?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/4293627/optional-output-parameters">Optional Output Parameters</a> </p> </blockquote> <p>I am currently working in a module wherein I need to add a new out parameter to a function which has been used in so many places! Instead of adding that new parameter everywhere i wish to make it as optional. Is there a way to use out parameter as an optional parameter? Please help me.</p>
c#
[0]
5,868,024
5,868,025
Avoid OutOfMemoryError in android
<p>Loading images onto ImageView in xml takes more memory?</p> <p>I Have an Activity with around 7 imageviews(just like the app tray in any android phone.)</p> <p>I am loading the images for each of the imageviews in the xml. Does this cause OutOfMemoryError? </p> <p>Is there a way to recycle these?</p>
android
[4]
783,673
783,674
PHP pagination loses variable on other pages- whats the solution?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/11638999/php-pagination-loses-variable-on-other-pages">PHP pagination loses variable on other pages</a> </p> </blockquote> <p>I am having the exact same issue that another member had. This issue was brought up by another member, Tatty27, and solved. The correct script however was not shown. Any ideas?</p> <p><a href="http://stackoverflow.com/questions/11638999/php-pagination-loses-variable-on-other-pages">PHP pagination loses variable on other pages</a></p>
php
[2]
2,469,422
2,469,423
Getting "multiple types in one declaration" error in C++
<p>Can anyone tell me why i get a "Block.h:20: error: multiple types in one declaration" error message when compiling this file. Nothing seems to be solving this problem and I'm getting pretty frustrated.</p> <p><strong>Displayable.h</strong></p> <pre><code>#include &lt;X11/Xlib.h&gt; #include &lt;X11/Xutil.h&gt; // Information to draw on the window. struct XInfo { Display *display; Window window; GC gc; }; // An abstract class representing displayable things. class Displayable { public: virtual void paint(XInfo &amp;xinfo) = 0; }; </code></pre> <hr> <p><strong>Sprite.h</strong></p> <pre><code>#include "Displayable.h" enum Collision { NO_COLLISION = 0, TOP_COLLISION, RIGHT_COLLISION, BOTTOM_COLLISION, LEFT_COLLISION }; class Sprite : public Displayable { public: int x, y, width, height; Sprite(); virtual void paint(XInfo &amp;xinfo) = 0; Collision didCollide(Sprite *s); }; </code></pre> <hr> <p><strong>Block.h</strong></p> <pre><code>#include "Sprite.h" class Block : public Sprite { public: virtual void paint(XInfo &amp;xinfo); Block(int x, int y, int width, int height); }; &lt;-- **This is line 20** </code></pre>
c++
[6]
1,968,253
1,968,254
Command prompt within another widget
<p>I have a GUI with label and entry widgets on a frame widget. I want to add a command prompt.to the frame through which the user can submit commands. I know about using the cmd module to create a prompt in the python shell, but I want the prompt to be part of my GUI window. Is there a way to 'embed' a command prompt in a canvas for example? Right now I am using Cmd.<strong>init</strong>(self) and cmdloop to start a prompt in python shell...</p> <p>Just to clarify further, I would like the shell to run from within my GUI window (e.g. inside a canvas), and not as its own window. Is that possible?</p>
python
[7]
5,217,296
5,217,297
Adapter for list view
<p>please guide me with this program. Why do we need to use an array adapter to show the list? What is this "adapter", and can we display things directly in the ListView, without an adapter? Like, can we set setListAdapter(names) instead of setListAdapter(adapter);? Thanks.<br> Here is the code:</p> <pre><code>import android.app.ListActivity; import android.os.Bundle; import android.widget.ArrayAdapter; public class Episode7 extends ListActivity { String[] names = { "Elliot","Geoffrey","Samuel","Harvey","Ian","Nina","Jessica", "John","Kathleen","Keith","Laura","Lloyd" }; /** Called when the activity is first created. */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Create an ArrayAdapter that will contain all list items ArrayAdapter&lt;String&gt; adapter; /* Assign the name array to that adapter and also choose a simple layout for the list items */ adapter = new ArrayAdapter&lt;String&gt;( this, android.R.layout.simple_list_item_1, names); // Assign the adapter to this ListActivity setListAdapter(adapter); } } </code></pre>
android
[4]
4,881,990
4,881,991
iphone - handle web page with in the application
<p>i'm currently working on iphone app which has a web view. i'm pulling a web page from internet and updating the web view. the web page has 3 text inputs: username, mail id and response code. it also has a button "play now". on click of play now, the data is posted to server and some processing is done there...... now,in my application, on click of "play now", i want to remove the web view and show my next view in application. can you please help me to achieve this or some solution for this problem?</p>
iphone
[8]
4,282,009
4,282,010
Override asp.net form tag
<p>I have master page that contains the following asp.net form tag</p> <pre><code>&lt;form id="CommerceMasterForm" runat="server"&gt; </code></pre> <p>on one page of my website i need to create normal html form from a user control</p> <pre><code>&lt;FORM action="http://externaldomain.com" method="post"&gt; </code></pre> <p>How can i override the asp.net form tag and make it post like a typical html form. </p>
asp.net
[9]
1,708,648
1,708,649
Android-Expandable List view
<p>How to move the group item to left when you deleted the default group indicator by using setGroupIndicator() method. </p>
android
[4]
3,486,292
3,486,293
Why does this floating-point calculation give different results on different machines?
<p>I have a simple routine which calculates the aspect ratio from a floating point value. So for the value 1.77777779, the routine returns the string "16:9". I have tested this on my machine and it works fine.</p> <p>The routine is given as :</p> <pre><code> public string AspectRatioAsString(float f) { bool carryon = true; int index = 0; double roundedUpValue = 0; while (carryon) { index++; float upper = index * f; roundedUpValue = Math.Ceiling(upper); if (roundedUpValue - upper &lt;= (double)0.1 || index &gt; 20) { carryon = false; } } return roundedUpValue + ":" + index; } </code></pre> <p>Now on another machine, I get completely different results. So on my machine, 1.77777779 gives "16:9" but on another machine I get "38:21".</p>
c#
[0]
2,205,498
2,205,499
redirecting the output of shell script executing through python
<p>Hi I am trying to execute shell script from python using following command.</p> <pre><code>os.system("sh myscript.sh") </code></pre> <p>in my shell script I have written some SOP's, now how do I get the SOP's in my Python so that I can log them into some file?</p> <p>I know using <code>subprocess.Popen</code> I can do it, for some reason I can not use it.</p> <pre><code>p=subprocess.Popen( 'DMEARAntRunner \"'+mount_path+'\"', shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT ) while 1: line=p.stdout.readline()[:-1] if not line: break write_to_log('INFO',line) p.communicate() </code></pre>
python
[7]
4,035,456
4,035,457
Php SimplePie library not working properly
<blockquote> <p>Deprecated: Assigning the return value of new by reference is deprecated in C:\Workspace\htdocs\feedBlurb\processing\simplepie.inc on line 738</p> </blockquote> <p>this is the error I get when I run the following SimplePie code on my server:</p> <pre><code>&lt;?php require_once("processing/simplepie.inc"); $feed = new SimplePie(); $feed-&gt;set_feed_url(array('http://feeds2.feedburner.com/CssTricks', 'http://smashingmagazine.com')); $feed-&gt;enable_cache(true); $feed-&gt;set_cache_location('core/cache'); $feed-&gt;set_cache_duration(1800); $feed-&gt;init(); $feed-&gt;handle_content_type(); ?&gt; &lt;!DOCTYPE html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;meta charset='UTF-8'&gt; &lt;title&gt;Feedblurb&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="content"&gt; &lt;h1&gt;Feedblurb&lt;/h1&gt; &lt;?php if($feed-&gt;error): ?&gt; &lt;span id='error'&gt;&lt;?php echo $feed-&gt;error; ?&gt;&lt;/span&gt; &lt;?php endif; ?&gt; &lt;?php foreach($feed-&gt;get_items() as $item): ?&gt; &lt;?php endforeach; ?&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>It seems like all instances of SimplePie don't seem to work on my server.. But I have a WordPress blog which is running SimplePie and that seems to work just fine. My development server is running the latest version of XAMPP. Any ideas?</p>
php
[2]
3,276,980
3,276,981
how to connect android and mysql server?
<p>I want to get the details from online mysql databse in android. I have wrote a php script to get the details form mysql database and convert the result as json string and extract the details in android using some sort of methods. I am new to android development I think there should be some simple way to do this. if so please let me know.</p>
android
[4]
3,794,327
3,794,328
Need help understanding this block of code (java)
<pre><code>public class Bicycle { private int cadence; private int gear; private int speed; public Bicycle(int startCadence, int startSpeed, int startGear) { gear = startGear; cadence = startCadence; speed = startSpeed; } </code></pre> <p>when you write gear = startGear; what does this actually do? does it temporary set the value of gear as whatever your input is for the time-being, then it resets back to zero? Is this called instance of a variable?</p> <p>And can someone explain to me what exactly is an "instance of an object"? is there one in here? I thought an instance of an object is when someone writes Bicycle bike1 = new Bicycle(); and bike1 is an instance of an object. Sorry I am a total noob.</p>
java
[1]
4,576,289
4,576,290
How to read output of hexdump of a file?
<p>I wrote a program in C++ that compresses a file.</p> <p>Now I want to see the contents of the compressed file.</p> <p>I used hexdump but I dont know what the hex numbers mean.</p> <p>For example I have:</p> <p><code>0000000 00f8</code><br> <code>0000001</code></p> <p>How can I convert that back to something that I can compare with the original file contents?</p>
c++
[6]
4,085,327
4,085,328
permutation of integer arrays
<p>I want a Java code for permutation of <code>int</code> arrays.</p> <p>Suppose an input of <code>1 2 3</code> and the program would return all the possible combinations of these elements.</p> <p>I have written a Java code which takes <code>String</code> array as an input and returns <code>int</code> array. But when I convert a <code>String</code> into an <code>int</code> array, I am facing a problem. The problem is that suppose I give an input of <code>10 20 2</code>, it goes <code>int</code> the <code>String</code> as <code>10 20 2</code> as it is. But on converting it into an <code>int</code> array it is getting converted as <code>1 0 2 0 2</code>.</p> <p>So plz post some Java code which does not need <code>String</code> conversion into an <code>int</code> array or plz give me suggestion so that i would get <code>10 20 2</code> in the <code>int</code> array in spite of <code>1 0 2 0</code>. I have used the following code for <code>String</code> to <code>int</code> array conversion.</p> <pre><code>for (int j= 0; j &lt; array[in].length(); j++) { intArray[j] = Character.digit(array[in].charAt(j), 10); } </code></pre> <p>Plz reply as soon as possible.</p>
java
[1]
5,179,660
5,179,661
Can the android API be used to intercept and read operator messages (USSD messages)?
<p>Through the android API is it possible for an android application to read the message sent by the mobile network operator as and when the user receives it as shown in the message below. If so how?:</p> <p><img src="http://i.stack.imgur.com/cC5cC.png" alt="Operator message regarding data usage in Android"></p>
android
[4]
982,704
982,705
How to get a file name based on last modified in php?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/5448374/get-last-modified-file-in-a-dir">get last modified file in a dir?</a> </p> </blockquote> <p>I have lot of file inside a folder. How can I get the last modified file name using php?<br> Is it possible? kindly help me.Thanks in advance.</p>
php
[2]
1,341,727
1,341,728
Integer storage - Hexadecimal/Octal
<p>I understand that integers are stored in binary notation, but I was wondering how this affects the reading of them - for example:</p> <p>Assuming </p> <pre><code>cin.unsetf(ios::dec); cin.unsetf(ios::hex); and cin.unsetf(ios::oct); </code></pre> <p>the user inputs</p> <pre><code>0x43 0123 65 </code></pre> <p>which are stored as integers. Now assume that the program wants to recognize these values as hex, oct, or dec and does something like this.</p> <pre><code>void number_sys(int num, string&amp; s) { string number; stringstream out; out &lt;&lt; num; number = out.str(); if(number[0] == '0' &amp;&amp; (number[1] != 'x' &amp;&amp; number[1] != 'X')) s = "octal"; else if(number[0] == '0' &amp;&amp; (number[1] == 'x' || number[1] == 'X')) s = "hexadecimal"; else s = "decimal"; } </code></pre> <p>the function will read all of the integers as decimal. I put in some test code after the string conversion to output the string, and the string is the number in decimal form. I was wondering if there is a way for integers to keep their base notation.</p> <p>Of course you could input the numbers as strings and test that way, but then there is the problem of reading the string back as an int. </p> <p>For example:</p> <pre><code> string a = 0x43; int num = atoi(a.c_str()); cout &lt;&lt; num; // will output 43 </code></pre> <p>It seems like keeping/converting base notation can get very tricky. As an added problem, the hex, dec, and oct manipulators wouldn't even help with the issue shown above since the integer is being stored completely incorrectly, it's not even converting to a decimal.</p>
c++
[6]
3,803,728
3,803,729
how do i check hosts in php?
<p>I want to match by hostname and I can't figure out how, </p> <p>example: i want to force all links to be from <code>oi*.tinypic.com</code> or <code>i*.tinypic.com</code>. However people bypass my current validation by using then adding hash at the back of the URL like <code>.jpg#tinypic</code>, if i use <code>stripos()</code> to prevent abuse on the forum.</p> <p>also, how do i check it's well formed url, of https or http? I'm using <code>parse_url()</code> and doing if <code>(!$var)</code> but it sometimes doesn't work for some reason i don't know</p>
php
[2]