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
6,009,784
6,009,785
Type Casting in c#
<p>I have a problem with declaring a <strong>type</strong> as passed from parameter type variable. </p> <pre><code>public static void ShowThisForm(Type passXtraForm, Form parent) { var xfrm = passXtraForm.GetType(); xfrm xfrmName = new xfrm(); xfrmName.Show(); } </code></pre> <p>Can I declare a variable as a type from passXtraForm.GetType() and declare it to another variable? Just passing the type of form to another class.</p> <p>Thanks in advance for the response.</p>
c#
[0]
616,712
616,713
low level socket connection to MySQL database Python
<p>Hello I would like to ask:</p> <p>How can I make a socket connection to a MySQL database (With out additional libraries) using only low level sockets so I can then send commands.</p> <p>Thank you for any help</p> <p>Edit is it also possible to connect over HTTP? (I wouldn't think that would make sense, but figured I would ask)</p>
python
[7]
4,708,824
4,708,825
PHP: get contents of li's within ul
<p>Ok I have about 12 pages included in a php page that look like this:</p> <pre><code>&lt;a name="1"&gt; &lt;/a&gt; &lt;h2&gt;Unit 1: Awareness of employment in the creative media sector&lt;/h2&gt; &lt;p /&gt; &lt;h3&gt; Learning outcomes:&lt;/h3&gt; &lt;ul class="outcomes"&gt; &lt;li class="n1"&gt;Know about employment status in the Creative Media sector&lt;/li&gt; &lt;li class="n2"&gt;Understand the Creative Media employment market place&lt;/li&gt; &lt;li class="n3"&gt;Be able to promote self&lt;/li&gt; &lt;/ul&gt; &lt;hr /&gt; &lt;ul class="files"&gt; </code></pre> <p>I want to be able to store the contents of the li's in an array, so I want to find grab the contents of each li within an ul with the class "outcomes" and push to array.</p> <p>Is this possible? I have heard of Xpath but it looks like jibberish to me, can anyone explain this more simply with some straightforward php or push me in the right direction for xpathing this?</p> <p>Thanks.</p>
php
[2]
3,524,730
3,524,731
Loading an apk file on an AT&T device for QA/testing when
<p>I'd love to get some ideas on best practices for testing our Android software, especially for AT&amp;T devices. We're using a Samsung Captivate, on AT&amp;T. As you know, AT&amp;T disables sideloading (no Unknowns Sources option in Settings->Applications).</p> <p>We need to have our QA team load our apk file onto these devices as part of our testing and validation process. We're willing to install the SDK if needed, and upload the apk file via USB. We are not willing to root the phone.</p> <p>Can I get any suggestions/ideas on how this can be done?</p> <p>Thank you,</p> <p>Tony</p>
android
[4]
798,192
798,193
Reload View only when application is opened Again
<p>My application has tab bar with one of the tabs having a segmented control on navigation bar. Based on segment clicked different view is displayed using a url. I am calling the url in viewdidload method.I do not want to use viewwillAppear to call the url as it will be called each time the view is displayed. I only want to call the url again whenever user closes the application and comes back.</p> <p>Whats the best way to do this.Should I remove the view controller from and reload it again once the application is opened.</p>
iphone
[8]
5,789,090
5,789,091
micromax funbook p600 tablet not showing connect in ubuntu system
<p>List of Devices is blank show. micromax funbook p600 tablet not showing connect in ubuntu system. Also not found vender id for micromax funbook.</p>
android
[4]
1,783,203
1,783,204
How to increment or decrement height of a div using jquery
<p>This is my attempt to decrement by 28:</p> <pre><code>var addItemForm = $('.add-item-form'); var h = addItemForm.height()-28; var h = toString(h); addItemForm.height(h); </code></pre> <p>But it doesn't work.</p>
jquery
[5]
445,153
445,154
Error: Could not find or load main class hello.world.HelloWorld
<p>I am trying to run this project called "hello user". I am new to Java, so wrote a simple program that takes your name, and displays "Hello ". while Running it, I get the following error:</p> <pre><code>run: Error: Could not find or load main class hello.world.HelloWorld Java Result: 1 BUILD SUCCESSFUL (total time: 0 seconds) </code></pre> <p>But when I run file <code>HelloWorld.java</code>, it does it fine</p> <p>I am doing this on Netbeans IDE 7.2</p>
java
[1]
1,736,460
1,736,461
deleting image from image folder
<p>I am working with an asp.net application.I want to delete a particular image from a folder 'image'.Image folder is located in application itself.When i am deleting some information from gridview ,then corresponding image in the 'image' folder should delete. Please help.(Image name is there in the grid view) </p>
asp.net
[9]
1,732,636
1,732,637
Method code in c# serialization
<p>When an object is serialized (by remoting to be sent across the wire) does the instance method code get serialized? Or are just the class level instance fields serialized?</p> <p>I am asking this as some of my objects have large method and want to know wheather I should be using DTO's (data transfer objects) for sending data across the wire.</p> <p>I guessing it's just the data plus some type version data ... am I right?</p> <p>Thanks</p>
c#
[0]
1,033,376
1,033,377
The underlying connection was closed: A connection that was expected to be kept alive was closed by the server
<p>Error Message: </p> <blockquote> <p>System.ServiceModel.CommunicationException: The underlying connection was closed: A connection that was expected to be kept alive was closed by the server.</p> </blockquote> <p><strong>Client</strong>: Windows .NET 4.0 framework Server: UNIX</p> <p><strong>Issue</strong> : The webservice connection was working fine with out any issues. But sometimes it was throwing the connection was closed error. I am new to .Net frame work and i know the basis. Please guide me how to fix this issue.</p> <p><strong>Work Around</strong>: After recycling the application pool the issue was fixed. (Actually we are closing the old connection and re-establishing).</p> <p>Any information to fix this issue will be greatly appreciated.</p>
asp.net
[9]
2,447,776
2,447,777
Building a tree "backwards"
<p>I need to create a tree-like structure in Python. I have a function get(parentId), which returns a list of objects with that parent -- I think that should be done recursively.</p> <p>The result should be something like this: <code>["root object", ["child1 of root", "child2 of root", ["child2-1", "child2-2"]]]</code></p> <p>Every object has a attribute parent, which is is the parentId for get(), but as a starting point I only have the root object.</p>
python
[7]
657,958
657,959
"unterminated string literal"
<p>I have the following PHP code:</p> <pre><code>$string .= '&lt;script&gt;addJSBeforeEndBody(\'$(document).ready(function() { bkLib.onDomLoaded(function() { nicEditors.allTextAreas() }); });\');&lt;/script&gt;'; </code></pre> <p>and the <code>addJSBeforeEndBody()</code> function:</p> <pre><code>function addJSBeforeEndBody(code) { $('body').append('&lt;script&gt;'+code.toString()+"&lt;/script&gt;"); } </code></pre> <p>Why do I keep getting an error:</p> <blockquote> <p>unterminated string literal</p> <p>$<code>('body').append('&lt;script&gt;'+code.toString()+"</code></p> </blockquote> <p>And an arrow points to <code>"</code> in Firebug.</p>
javascript
[3]
2,016,058
2,016,059
Using multiple values with strstr($_SERVER['PHP_SELF']...)
<p>another simple thing that's got me stuck:</p> <p>I'm using the following to check on the current url and select a div class dependent on the result:</p> <pre><code>$checkit = $_SERVER['PHP_SELF']; ... &lt;li "; if(strstr($checkit,'welcome')) { echo "class='active_tab'"; }... </code></pre> <p>What I want to be able to do is also check if the url includes other words which would also require that same 'li' item to be given the 'active_tab' class, but i can't figure out the format. Something like this, although obviously this doesn't work:</p> <pre><code>&lt;li "; if(strstr($checkit,'welcome', 'home', 'yourprofile')) { echo "class='active_tab'"; }... </code></pre> <p>Can someone help?</p>
php
[2]
4,757,368
4,757,369
Add multiple fields to Java 5 HashSet at once?
<p>Is there a better way to do this so I don't have to have 50 ".add()"s in there? Like a comma separated list or something (like JavaScript arrays).</p> <pre><code>private static final Set&lt;String&gt; validStates = new HashSet&lt;String&gt;(); validStates.add("AL"); validStates.add("AK"); validStates.add("AZ"); validStates.add("AR"); validStates.add("CA"); validStates.add("CO"); validStates.add("CT"); validStates.add("DE"); validStates.add("DC"); validStates.add("FL"); validStates.add("GA"); validStates.add("HI"); validStates.add("ID"); validStates.add("IL"); validStates.add("IN"); validStates.add("IA"); validStates.add("KS"); validStates.add("KY"); validStates.add("LA"); validStates.add("ME"); validStates.add("MD"); validStates.add("MA"); validStates.add("MI"); validStates.add("MN"); validStates.add("MS"); validStates.add("MO"); validStates.add("MT"); validStates.add("NE"); validStates.add("NV"); validStates.add("NH"); validStates.add("NJ"); validStates.add("NM"); validStates.add("NY"); validStates.add("NC"); validStates.add("ND"); validStates.add("OH"); validStates.add("OK"); validStates.add("OR"); validStates.add("PA"); validStates.add("RI"); validStates.add("SC"); validStates.add("SD"); validStates.add("TN"); validStates.add("TX"); validStates.add("UT"); validStates.add("VT"); validStates.add("VA"); validStates.add("WA"); validStates.add("WV"); validStates.add("WI"); validStates.add("WY"); </code></pre> <p>Something like:</p> <pre><code>validStates.add("AL", "AK", "..."); </code></pre>
java
[1]
5,451,351
5,451,352
How do I change the image on a <asp:buttonField type="Image" /> in code behind?
<p>I have a <code>&lt;asp:GridView &gt;</code> with a <code>&lt;asp:ButtonField ButtonType="Image"&gt;</code> as one of the columns.</p> <p>Here's the problem: I have to dynamically change the image of this ButtonField during the <code>gridView_RowDataBound(...)</code> event based on the data found in that particular gridview row. </p> <p>The real question is, is how to access that particular ButtonField inside the <code>gridView_RowDataBound(...)</code> event so I can change its image in C# code?</p> <p>I can't use </p> <pre><code>Image imgCtrl = (Image)args.Row.FindControl("ctrlID"); </code></pre> <p>because the <code>&lt;asp:ButtonField&gt;</code> won't allow an ID to be set (get a parser error when I try to run the webPage). And I can't use</p> <pre><code>args.Row.Cells[0].Controls[0]; </code></pre> <p>because the zeroth index of the .Controls[0] doesn't exist (I get a boundry overflow error).</p> <p>There's got to be a simple, slick, easy way to do this!</p>
asp.net
[9]
589,333
589,334
Best practice for filing of abstract class and subclasses?
<p>I was wondering what is the best (and real-word) practice for doing an abstract class and subclasses in PHP when it comes to filing.</p> <p>I have <code>abstract class games</code>, and I was wondering if I should put the subclasses into separate files and <code>require_once('games.class.php');</code> for separate files or just have each subclass in the <code>abstract class games</code> file?</p> <p>Thanks!</p>
php
[2]
4,823,963
4,823,964
Android Device install new font
<p>I need to install Tamil font in to my Android device. is it possible to install new Unicode font in to the android device?</p> <p>Thanks, Chandnaa</p>
android
[4]
5,549,812
5,549,813
Redirect to a mobile app from a web page
<p>How to open an android application when a particular link in mobile browser,is clicked? Thanks in advance</p>
android
[4]
1,802,120
1,802,121
Getting WebView content, or cookies
<p>Is there a way to get the current content of a WebView?</p> <p>What about Cookies for a specific host+url?</p>
android
[4]
4,126,446
4,126,447
Example of how to use TreeView_SortChildrenCB
<p>Raymond Chen wrote:</p> <blockquote> <p>"The <code>TreeView</code> common control does not support moving items to a new parent. If you want to >move an item relative to its siblings (but remain under the same parent), you can use ><code>TreeView_SortChildrenCB</code> and pass a custom sort function that orders the children the way you >want."</p> </blockquote> <p>Is there an example anywhere of exactly how to call <code>TreeView_SortChildrenCB</code> to sort according to an arbitrary ordering (e.g., sorting doubles or strings)? The documentation is anything but clear to someone who is an experienced C++ programmer but isn't familiar with this function.</p> <p>Thanks.</p>
c++
[6]
4,561,655
4,561,656
Streaming Using Video View works fine but after playing some video Gives Dialog Can Not Play this video
<p>I am using Video View To stream Video.</p> <p>I am able to start video successfully But what happens is after playing some video I am getting Dialog Box saying Can not play this video.</p> <p>When I tried multiple times then I realized that It shows me dialog at random length of video played.</p> <p>I don't able to find why this is happening.</p>
android
[4]
5,282,457
5,282,458
How can I use text from an EditText Field into a web page?
<p>I am creating a library search engine based on android. I want to have an EditText field in my application, where user will put the search text. And upon clicking the search button it should search using the library web page. I want to use the text being put in the EditText field to be used by the web page in the background and want to show the result to the user. Could find a clue. I will be really grateful if you could answer asap.</p> <p>Thanks. / Hasibur Rahman </p>
android
[4]
5,504,539
5,504,540
What are the changes I have to made in php.ini to move the uploaded files to a remote server?
<p>My php application is running in a master-slave server with load balance. Some times the upload request will redirect to the slave server and the files will uploaded to the slave only. It will not sync with the master. I want to change the file upload path of the apache server of slave to master. What should I do in php.ini to achieve this without making modification in my application?</p>
php
[2]
6,007,795
6,007,796
ASP.Net Website, I'm exposing functionality externally how can I limit duplicate code?
<p>Some of my clients are off of our internal network and I'm going to be exposing a few reports to the internet. This means that I'll have 2 separate sites one with admin fucntions and reports on our intranet and one with just reports exposed to the internet. </p> <p>The pages that I'll be duplicating are fairly simple. Asp chart controls with a few other fields for choosing time span, size of report, relevant filters etc.</p> <p>What are some ways to reduce the amount of duplicate code in 2 nearly identical ASP .Net websites?</p> <p>Compiling UserControls into libraries? CSS files in a resource file? Put app_code somewhere else? How would I do any of these if they are possible?</p> <p>My websites will be on completely different web servers and will be sharing the same SQL Server 2005 DB. </p>
asp.net
[9]
4,628,836
4,628,837
How do i get file path of my file in java enterprise application?
<p>I created java enterprise application and it consists of ejb module and web application. I have plain old xml file in source packages folder in package "common" in my ejb module. I want to pass this file path in File() constructor for one class in ejb module. How do i do it?</p> <p>If i pass any of the below it doesn't work :-</p> <pre><code>new File("abc.xml"); //this take file from glassfish/domains/domain1 :( new File("./abc.xml"); </code></pre> <p>I don't want to pass hardcode path like /home/administrator/appname/module/etc..</p> <p>I want the path relative from my ejb module. Please help me. I've tried all things.</p> <p>Actually when i created a class in same folder and then try <code>classname.getResource("abc.xml").getPath()</code> it works fine. But what if i don't have any class in that folder. Waiting for your replies</p>
java
[1]
4,873,273
4,873,274
ListView row highlight when data changes
<p>I have a <code>ListView</code> in which data is streaming (changing). I want to just highlight the row for a fraction of seconds when the data is changing and then comes back to old state.</p> <p>any solution?</p>
android
[4]
1,498,649
1,498,650
Master page and performance
<p>Can master pages increase performance of the application in case of loading time or it is just to reuse the design and making consistency. Or has it overhead(taking time) while events execution for both the content page and master page.</p>
asp.net
[9]
2,234,070
2,234,071
Passing a string as a reference in Java?
<p>I don't think i have the terminology correct, haven't been one for that. What i'm trying to do is get a string back , then use it to run functions. .. Example :</p> <pre><code>int slotNumber = ((j*3)+i+1); String slotString = "slot"+slotNumber; </code></pre> <p>Regularly I can do this :</p> <pre><code>slot12.Draw(); </code></pre> <p>And I want to be able to do this :</p> <pre><code>slotString.Draw(); </code></pre> <p>With it substituting slotString with slot12 in a dynamic scenario. If i truly have to i could do something similar to :</p> <pre><code>if (slotString == slot1) slot1.Draw(); if (slotString == slot2) slot2.Draw(); </code></pre> <p>And such, but i dont really want to use x number of lines for x number of slots.</p> <p>Any help is appreciated :D</p>
java
[1]
1,247,102
1,247,103
Link should be open in same web view in Android
<p>I am new in Android and I am trying to open a Link in webview using this code</p> <pre><code>WebView myWebView = (WebView) findViewById(R.id.webinfo); myWebView.loadUrl("http://oslobokfestival.netteam.no/artical.php?articalid=93"); myWebView.setBackgroundResource(R.drawable.lbg); myWebView.setBackgroundColor(Color.TRANSPARENT); myWebView.getSettings().setJavaScriptEnabled(true); </code></pre> <p>and in this HTML page contains some links and I want that when user click that link should be open in same webview, at this point its opening in mobile browser, please give me appropriate solution.. Thanks. </p>
android
[4]
3,439,991
3,439,992
Adding fisheye plug-in fails to animate() on mouseleave
<p>Here is a weird one.</p> <p>I have an auto-hiding toolbar, which worked perfectly, until I added plug-in called FishEye (aka Interface elements). I did not even use it, I just added it.</p> <p>With that plug-in loaded, my toolbar fails to animate on mouseleave.</p> <p><a href="http://jsfiddle.net/wYmvk/" rel="nofollow">http://jsfiddle.net/wYmvk/</a> (once you remove eval() with that plug-in - things are back to normal)</p> <p>I really need this plug-in and don't wanna loose my toolbar. =)</p> <p>Please help resolving. Thanks.</p>
jquery
[5]
5,042,732
5,042,733
Loop through poco-class properties
<pre><code>public partial class Foo { public struct ContainerOne { public const long Sub1 = 1; public const long Sub2 = 2; } public struct ContainerTwo { public const long Sub3 = 3; public const long Sub4 = 4; } } </code></pre> <p>Is there any way to make a nested foreach that gets each container name, with an inne loop that gets each property name + value?</p> <p>Hope you get the idea, otherwise ill elaborate, thanks!</p>
c#
[0]
4,904,241
4,904,242
getting error when click on the Image button?
<p>in my application i have vidoes there with image when i click on any video it is showing this message.</p> <p>Invalid postback or callback argument. Event validation is enabled using in configuration or &lt;%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation. </p> <p>i place the enbaleEven validation="true" both in webconfig in that particular page. even though it is giving same error </p>
asp.net
[9]
3,098,943
3,098,944
Transparent Activity floating/draggable on Homscreen
<p>I know how to create a simple transparent activity, but how do I have both Transparent activity and draggable across the screen. Best example I can think of is the <a href="https://play.google.com/store/apps/details?id=com.myboyfriendisageek.airbrowser&amp;feature=search_result#?t=W251bGwsMSwxLDEsImNvbS5teWJveWZyaWVuZGlzYWdlZWsuYWlyYnJvd3NlciJd" rel="nofollow">Overskreen app on Google Play.</a></p>
android
[4]
4,247,334
4,247,335
grabbing Html of $(this) in Jquery
<p>How can I grab the Html for <code>$(this)</code> in a following function </p> <pre><code>allhdn.each(function (){ var $this = $(this); var newHtml = (str + $this.html()); }); </code></pre> <p><code>$(this).html()</code> returns empty string.</p>
jquery
[5]
1,052,781
1,052,782
Retrieving the Selected RadioBox Checked value dynamically passing radioname in JQuery
<p>i have group of radio buttons in different name. I have to select those values dynamically. here is a example code of that.</p> <pre><code> &lt;input type="radio" id="@(item2.QuestionId):@(item3.OptionId)_mt" columnvalue="@i" value="@(item2.QuestionId):@(item3.OptionId)" name="@(item2.QuestionId)_selectedobjects" /&gt; </code></pre> <p>when i click submit button i get those arrays.</p> <pre><code> var name={748_selectedobjects, 749_selectedobject, 750_selectedobjects} </code></pre> <p>now i need to find out the radio box selected for each name. how can i do this in Jquery.</p> <p>I am trying with </p> <pre><code> $('input[name=748_selectedobjects]:checked').Val(); </code></pre> <p>how can i pass name dynamically ?</p> <p>Thanks.</p>
jquery
[5]
5,911,678
5,911,679
How to target parent of a hyperlink in Jquery
<p>I have some HTML that looks like this:</p> <pre><code>&lt;div class="product"&gt; Content In Here &lt;div class="price"&gt; &lt;a href="#" class="removeLink"&gt;Remove&lt;/a&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>I'm trying to target the parent of the remove link like this:</p> <pre><code>$('.removeLink').click(function(event) { event.preventDefault(); $(this).parent('.product').fadeOut('fast'); }); </code></pre> <p>However for some reason it's not working and I can't figure out why, there is no error messages in the Javascript console, any idea why it won't fade out the parent .product div?</p>
jquery
[5]
1,204,265
1,204,266
Making pyramid using c#
<p>My question is how to make a pyramid using * and 'space' in C#? The output will be like this.</p> <pre><code> * * * * * * * * * * * * * * * </code></pre> <p>We only need to use "for loop" for this program. I only know how to make this one.</p> <pre><code>* ** *** **** ***** </code></pre> <p>I made a program like this:</p> <pre><code>static void Main(string[]args) { int i=o; int j=o; for(i=5;1&gt;=1;i--) for(j=1;j&lt;=5;j++) { Console.Write("*"); } Console.WriteLine(" "); } </code></pre> <p>I'm confused when it comes to pyramid because it includes spaces. Thanks for your help!</p>
c#
[0]
3,259,643
3,259,644
PHP print_r shows array and not plain text only
<p>I am once again looking for some help.</p> <p>I have found this stopwords script - I basically remove all common words from a string.</p> <pre><code>&lt;?php $CommonWords = file_get_contents('http://localhost/stopwords.txt'); $CommonWords = explode("\n", $CommonWords); $CommonWords = array_map('trim', $CommonWords); // &lt;---- ADD THIS LINE $keywords = 'The &lt;meta&gt; tag’s keyword attribute is not the page rank panacea it once was back in the prehistoric days of Internet search. It was abused far too much and lost most of its cachet. But there’s no need to ignore the tag. Take advantage of all legitimate opportunities to score keyword credit, even when the payoff is relatively low. Fill in this tag’s text with relevant keywords and phrases that describe that page’s content'; $search_keywords = strtolower(trim($keywords));$arrWords = explode(' ', $search_keywords); $arrWords = array_unique($arrWords); foreach ($arrWords as $word) { if (!in_array($word, $CommonWords) &amp;&amp; (trim($word) != '')) { $searchWords[] = $word; } } print_r($searchWords); ?&gt; </code></pre> <p>The output for the code looks like this: </p> <pre><code>Array ( [0] =&gt; [1] =&gt; tag’s [2] =&gt; keyword [3] =&gt; attribute [4] =&gt; page [5] =&gt; rank [6] =&gt; panacea [7] =&gt; prehistoric [8] =&gt; days [9] =&gt;) </code></pre> <p>How can I format it so that the output looks like this: (without the Array and numbers)</p> <pre><code>tag's, attribute, page, rank, panacea, prehistoric, days </code></pre> <p>Thanks</p>
php
[2]
4,405,872
4,405,873
Is ASP.Net a technology suitable for high-load sites?
<p>That's the question... Do you think ASP.Net is a technology suitable for high-load sites? Do you know any populer sites -apart from stackoverflow, of course- built with this technology? Thanks.</p>
asp.net
[9]
2,431,678
2,431,679
iPhone - adding a UISegmentedControl to a Navigation Controller Toolbar
<p>Is this an heresy to add a UISegmentedControl to a navigation Controller Toolbar?</p> <p>I am considering this code:</p> <pre><code>UISegmentedControl *segmentedControl = [[UISegmentedControl alloc] initWithItems: [NSArray arrayWithObjects: [NSString stringWithString:NSLocalizedString(@"One", @"")], [NSString stringWithString:NSLocalizedString(@"Two", @"")], [NSString stringWithString:NSLocalizedString(@"Three", @"")], [NSString stringWithString:NSLocalizedString(@"Four", @"")], nil]]; segmentedControl.segmentedControlStyle = UISegmentedControlStyleBar; segmentedControl.tintColor = [UIColor blackColor]; [segmentedControl setSelectedSegmentIndex:0]; [segmentedControl addTarget:self action:@selector(changeSegment:) forControlEvents:UIControlEventValueChanged]; [segmentedControl setFrame:[self.navigationController.toolbar bounds]]; [self.navigationController.toolbar addSubview:segmentedControl]; [segmentedControl release]; </code></pre> <p>I have tried this code and the segments don't appear to be selected with I touch them.</p> <p>Is this the correct way of doing that?</p> <p>thanks.</p>
iphone
[8]
1,511,495
1,511,496
C# How can I read all jpeg files in a directory using a Filestream so the files aren't locked?
<p>How can I read all jpeg files in a directory using a Filestream so the files aren't locked? My current code is below, there is no mention of Filestream as I can't get it to work. Many thanks for any help.</p> <pre><code> public Form1() { InitializeComponent(); images = new List&lt;Image&gt;(); // add images DirectoryInfo di = new DirectoryInfo(@"\\server\files\"); FileInfo[] finfos = di.GetFiles("*.jpg", SearchOption.TopDirectoryOnly); foreach (FileInfo fi in finfos) images.Add(Image.FromFile(fi.FullName)); } private void buttonNext_Click(object sender, EventArgs e) { index++; if (index &lt; 0 || index &gt;= images.Count) index = 0; pictureBox1.Image = images[index]; int count = index + 1; labelCount.Text = "Showing " + count.ToString() + " of " + images.Count; } </code></pre>
c#
[0]
5,811,314
5,811,315
JavaScript identifiers not to use
<p>I just found out the hard way that naming your variable <code>arguments</code> is a bad idea.</p> <pre><code>var arguments = 5; (function () { console.log(arguments); })(); </code></pre> <blockquote> <p><code>Output: []</code></p> </blockquote> <p>It turns out that <code>arguments</code> is <a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Functions_and_function_scope/arguments">"a local variable available within all functions"</a> so in each new execution context, <code>arguments</code> is shadowed.</p> <p>My question is: Are there any other such treacherous names which, like <code>arguments</code>, are not true <a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Reserved_Words">reserved words</a>, but will cause still problems?</p>
javascript
[3]
241,938
241,939
Exception on sessionDestroyed when calling another beans method
<p>I am facing problem when i am calling database insert method under </p> <pre><code>public void sessionDestroyed(HttpSessionEvent se) </code></pre> <p>sessionDestroyed threw exception of </p> <pre><code>Session event listener threw exception java.lang.NullPointerException </code></pre> <p>my complete code looks like </p> <pre><code>public void sessionDestroyed(HttpSessionEvent se) { UserInfo currentUser = new UserInfo(); AccessHistory loginHist = new AccessHistory(); HttpSession session = se.getSession(); if (session != null) { if (session.getAttribute("userInfo") != null) { currentUser = (UserInfo) session.getAttribute "userInfo"); if (currentUser.getUserId() != null ) { if(!currentUser.getUserId().isEmpty()){ loginHist.setUserId(currentUser.getUserId()); try { getAccessHistoryDAO().maintHistory(loginHist, false); } catch (DAOException e) { e.printStackTrace(); } } } } } </code></pre> <p>any help will be greatly appricated. thank you.</p>
java
[1]
501,211
501,212
Which method is more efficient String.equals(String s) or String.contains(String s)
<p>For example, if I have a the following:</p> <pre><code>String s = "Alexander"; </code></pre> <p>which is more efficient in this case, checking:</p> <pre><code>if(s.contains("Alexander")) return true; </code></pre> <p>OR</p> <pre><code>if(s.equals("Alexander")) return true; </code></pre> <p>Please note that this is just a basic example, all I need to know is understanding the root of method..Which is more efficient or faster?</p>
java
[1]
480,746
480,747
How to create a singleton class based on its input?
<p>I have a class defined as </p> <pre><code>class Conditional_Singleton(object): def __init__(self, condition=None): self.initialization = some_func_of(condition) </code></pre> <p>Since the "initialization" step really takes a lot of time to run and the output could be huge, I would really like that the class not be recreated over and over again given the same input, but do so once the input changes. Any ideas? </p>
python
[7]
5,124,661
5,124,662
Can I add an event to an object before it is created?
<p>I have the following that is created dynamically:</p> <pre><code>&lt;a class="editLink" href="/location/Edit?city=05"&gt;Edit&lt;/a&gt; </code></pre> <p>This and other editLink rows are created dynamically. </p> <p>What I would like to do is add some jQuery to these:</p> <pre><code>$(".editLink").button(); $(".editLink").click(function () { alert('edit link'); return false; }); </code></pre> <p>Is there some way I can assign this BEFORE the elements appear? Also how can I deal with the following:</p> <pre><code>$(".editLink").button(); </code></pre> <p>When the .editLink is not already there.</p>
jquery
[5]
1,818,059
1,818,060
php: forcedownload on my own server - check if file exists?
<p>hey guys, i'm using a force-download script on my own server. - click on a link and the file prompts as download. works perfect, but even if a file does not exist it can be downloaded as empty file. so if i set a link with /folder/filexyz.txt it prompts the download and an empty txt-file gets downloaded to the harddrive.</p> <p>i'm currently using this script:</p> <pre><code>header("Cache-Control: no-cache"); header("Expires: -1"); header("Content-Type: application/octet-stream;"); header("Content-Disposition: attachment; filename=\"" . basename($file) . "\";"); header("Content-Transfer-Encoding: binary"); header("Content-Length: " . filesize($file)); echo readfile($file); </code></pre> <p>$file is the complete path to my file like: <a href="http://www.mydomain.com/folder1/folder2/folder/filexyz.txt" rel="nofollow">http://www.mydomain.com/folder1/folder2/folder/filexyz.txt</a></p> <p>how can i check if the file exists or not. If it's not there the download should not prompt, otherwise of course yes.</p>
php
[2]
2,339,833
2,339,834
How do I get a Google MapView to display more than just a grid?
<p>When I run a simple MapView app, the map shows up as a grid - no image of countries like it should be.</p> <p>I've read through several tutorials saying that I need to include Internet permissions as a child of my manifest tag in the Android Manifest, which I've placed in the file.</p> <p>I also need to generate a fingerprint out of my debug.keycode file and register it with Google for a key, which I've done. I've included this key in my XML layout. Still, I only get a grid when I run the app. I've registered my key a couple times and got the same result. Has anyone else had and overcome this issue? I've seen this same question posted under tutorials, but nobody had an answer. Thanks!</p>
android
[4]
1,184,791
1,184,792
how to update spinner2 based on spinner1 choice
<p>I have to develop the application based on spinner. </p> <p>so i have taken the spinner1 as the product choice and i have to give the spinner2 the data. which is in that particular product category so i have to update spinner2 on the base choice of spinner1.</p> <p>i have search a lot but i can get any sure example code or resouce for it . so please help me to do so.</p>
android
[4]
2,436,543
2,436,544
nested php ternary trouble: ternary output != if - else
<p>I am fairly capable at using the PHP ternary operator. However I have hit a roadblock at trying to figure out why the code below does not match the if-else equivalent structure. The test was run three times on different numbers. The output for each structure is below the code.</p> <p>Ternary:</p> <pre><code>$decimal_places = ($max &lt;= 1) ? 2 : ($max &gt; 3) ? 0 : 1; </code></pre> <p>Ternary Output:</p> <blockquote> <p>max: -100000 decimal: 0 </p> <p>max: 0.48 decimal: 0 </p> <p>max: 0.15 decimal: 0</p> </blockquote> <p>If-Else</p> <pre><code>if($max &lt;= 1) $decimal_places = 2; elseif($max &gt; 3) $decimal_places = 0; else $decimal_places = 1; </code></pre> <p>If-Else Output:</p> <blockquote> <p>max: -100000 decimal: 2 </p> <p>max: 0.48 decimal: 2</p> <p>max: 0.15 decimal: 2</p> </blockquote> <p>Can anyone please tell me why the these two control stuctures do not output the same data?</p>
php
[2]
1,308,388
1,308,389
sort and group a java collection
<p>I have an object which has a name and a score. I would like to sort a collection of such objects so that they are grouped by name and sorted by maximum score in each group (and within the group by descending score as well).</p> <p>let me demonstrate what I intend to achieve. assume I have these objects(name, score):</p> <p>(a, 3)<br> (a, 9)<br> (b, 7)<br> (b, 10)<br> (c, 8)<br> (c, 3)</p> <p>then I would like them to be sorted like this:</p> <p>(b, 10)<br> (b, 7)<br> (a, 9)<br> (a, 3)<br> (c, 8)<br> (c, 3)</p> <p>is this feasible with a Comparator? I can't figure it out, so any hints would be appreciated.</p>
java
[1]
3,348,940
3,348,941
Uncheck check box some other action
<p>I know it may look wierd but everything works fine except the bit where iam tryin to grab the id and attach it to the [name=checkme]</p> <p>How do i go about formatting that line so that the id will be recoginsed. </p> <pre><code>$('input:checkbox[name=checkme'+id+']').attr('checked',""); </code></pre> <p>It wont work as is but if i remove the +id it works and unchecks all checkboxes.</p> <p>Hope that makes sense :)</p> <p>Here is my code:</p> <pre><code> &lt;script type="text/javascript"&gt; function deleterow(id) { var txt = $.ajax({ (do stuff here) }).success $('input:checkbox[name=checkme'+id+']').attr('checked',""); } &lt;/script&gt; </code></pre>
jquery
[5]
3,131,203
3,131,204
Is a Python list guaranteed to have its elements stay in the order they are inserted in?
<p>If I have the following Python code</p> <pre><code>&gt;&gt;&gt; x = [] &gt;&gt;&gt; x = x + [1] &gt;&gt;&gt; x = x + [2] &gt;&gt;&gt; x = x + [3] &gt;&gt;&gt; x [1, 2, 3] </code></pre> <p>Will <code>x</code> be guaranteed to always be <code>[1,2,3]</code>, or are other orderings of the interim elements possible?</p>
python
[7]
1,252,592
1,252,593
How is the object std::cout constructed/instantiated
<p>So std::cout is an object. My doubt is how/where is it constructed/instantiated.</p> <p>Thanks.</p>
c++
[6]
5,231,610
5,231,611
Using the merge tag in layouts to add external layout resource?
<p>I have a layout I want to reuse, it looks like:</p> <pre><code>&lt;LinearLayout .. &gt; &lt;Button /&gt; &lt;/LinearLayout&gt; </code></pre> <p>It is in a file called "reuseme.xml". Now I have an activity layout, which like the following, how can I incorporate the layout above into it?:</p> <pre><code>&lt;LinearLayout&gt; &lt;TextView /&gt; &lt;TextView /&gt; &lt;ReuseMeLayout /&gt; // How do we add this here? &lt;/LinearLayout&gt; </code></pre> <p>It seems that's possible, but I'm not sure how to use the merge tag to accomplish it?</p>
android
[4]
4,065,538
4,065,539
Python: Can't get correct data type
<p>I am new to Python programming. I encountered a problem in one of the exercises and can't think of a way out. So, I have to check whether an input is "int" or "float" and return it's absolute value. An error message otherwise. I chose to use 'raw_input()' to accept an input from the user, but the problem is that it accepts inputs as a string. again, I am new to Python so please excuse me if this question seems to be dumb, but I really need help with this. I have added the question and my code too. Thanks!!</p> <p>Question:</p> <p>This is a two-parter: first, define a function, distance_from_zero, with one parameter (choose any parameter name you like). Second, have that function do the following: Check the type of the input it receives. If the type is int or float, the function should return the absolute value of the function input. If the type is any other type, the function should return "This isn't an integer or a float!"</p> <p>Code:</p> <pre><code>def distance_from_zero(n): n=raw_input("Please enter a number:") if type(n)==int or type(n)==float: print abs(n) else: print "This isn't an integer or a float!" </code></pre>
python
[7]
3,547,692
3,547,693
Is this how to make a keyword finder/density check?
<p>Hi I have a relatively big block of text and am wanting to find the most common keywords within it and calculate the density of these keywords. The way that I have thought of seems as though it could be slow or performance demanding and difficult:</p> <p>Iterate over each word in the block of text.<br> Find all the same matches for each of these words Count the total matches for each of these words Take say the top 5 most matches and then calculate their density relative to total block. output results</p> <p>Is there any easy quick better way of doing this using jquery?</p>
jquery
[5]
118,809
118,810
Determining if an array of NULL values is considered empty
<p>I'm building an array to determine if I need to take an action. I am executing a query. The table has a <code>sent_date</code> field to determine if an email has been sent to a user or not. Once it has been sent to a user, that <code>sent_date</code> field is populated with <code>getdate()</code>. Here is how I'm building:</p> <pre><code>$sent_date_sql = " select ind_id, sent_date from profileemail "; $results = dbExec($sent_date_sql); </code></pre> <p>I then build my array:</p> <pre><code>foreach ($results as $r){ array_push($sent_date,$r['sent_date']); $query_count = count($results); } </code></pre> <p>This all is working gloriously. My issue is when I go to check the <code>sent_date</code> array. The first time in the month that this script runs, ALL <code>sent_date</code> values are NULL. So my array looks like:</p> <pre><code>array(228) { [0]=&gt; NULL [1]=&gt; NULL [2]=&gt; NULL [3]=&gt; NULL [4]=&gt; NULL </code></pre> <p>...etc.</p> <p>Now I am going to try to evaluate <code>$sent_date</code>:</p> <pre><code>if(empty($sent_date)){ </code></pre> <p>My <code>empty</code> condition never hits because the values of the array are all NULL. Is there an alternative way to achieve what I am trying to do? Should I be looping through my <code>$sent_date</code> array and evaluating each value?</p>
php
[2]
1,293,500
1,293,501
Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /home/xxxx/public_html/sub-domain/templates/xxxxx/index.php on line 66
<p>I'm facing above problem. The piece of code is given below:</p> <pre><code>&lt;?php foreach ($feed as $entry) { $videoId = $entry-&gt;getVideoId(); $thumbnailUrl = $entry-&gt;medx-MoBiLeroup-&gt;thumbnail[0]-&gt;url; $videoTitle = $entry-&gt;medx-MoBiLeroup-&gt;title; $viewCount = $entry-&gt;statistics-&gt;viewCount; $authorUsername = $entry-&gt;author[0]-&gt;name; $videoDescription = $entry-&gt;medx-MoBiLeroup-&gt;description; $videoRating = $entry-&gt;rating-&gt;average; $duration = $entry-&gt;medx-MoBiLeroup-&gt;duration-&gt;seconds; $videoTitle2 = substr($videoTitle, 0, 40); $newtitle = ucwords(str_replace($string, $replace, $videoTitle)); //$desc = htmlspecialchars(wordwrap(substr($videoDescription, 0, 100) . '...', 30, ' ', 1)); enter code here </code></pre>
php
[2]
1,738,958
1,738,959
How do I manage with dynamic id's
<p>I am automating a test case, where I need to focus on a link, then I have to click on a element say element id looks like <code>//table[@id='562']/tbody/tr/td[2]/img</code>, but the value inside quotes that is 562 is keep changing how can i find out and click that element. Please can any body help me.</p>
javascript
[3]
1,937,013
1,937,014
javascript split string to get Date and Hours only
<p>I have this date format ,</p> <pre><code>var dateobj = 'Apr 28, 2011 6:01:23 AM'; </code></pre> <p>I need Apr 28 6 (That is only date and hours )</p> <p>Please tell me </p> <p>I tried this way </p> <pre><code>var amorpm = dateobj.split(' ').slice(0, 3).join(' '); but i am getting only date </code></pre>
javascript
[3]
2,819,102
2,819,103
PHP Preg_replace() function
<p>How to use the preg_replace function to replace </p> <p>/c83403.403/</p> <p>Example: <a href="https://startimage.ca/c83403.403/ahmedmynewpix.jpg" rel="nofollow">https://startimage.ca/c83403.403/ahmedmynewpix.jpg</a></p> <p>another example: <a href="https://startimage.ca/c2.3403.403/ahmedmynewpix2.jpg" rel="nofollow">https://startimage.ca/c2.3403.403/ahmedmynewpix2.jpg</a></p> <p>It always start with /c..../ I want to replace that with ""</p> <p>I am trying the following but not working $str = '/c..../'; $str = preg_replace('/+[0-9]', '', $str);</p>
php
[2]
4,439,342
4,439,343
radiobuttonlist alignment
<p>Does anyone know how to make a radiobuttonlist appears horizontally with text on the bottom, in ASP.Net?</p> <pre><code> . . . Option 1 Option 2 Option 3 </code></pre>
asp.net
[9]
544,163
544,164
Indicator to indicate vibration on the phone
<p>Currently I am developing a app which would vibrate morse code.</p> <p>I am using this code to vibrate the pattern:</p> <pre><code>int dot = 100; int dash = 220; int short_gap = 200; int medium_gap = 700; s = new long[] {0, dot, short_gap, dash, medium_gap} Vibrator vibrator; vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); vibrator.vibrate(s, -1); </code></pre> <p>How do I add an indicator to indicate if my application is vibrating a dot or a dash? </p> <p>I know I can use a for loop to transverse the <code>long[]</code> and then use a if else statement to change a textview background colour to indicate a change in the pattern. But how do I get the for loop to keep within the vibration ms for each change? </p>
android
[4]
5,761,131
5,761,132
python ............. delete
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/4357499/python-delete-in-a-string">Python delete in a string</a> </p> </blockquote> <p>I have the following list which has 3 elements:</p> <p>YELLOW,SMALL,STRETCH,ADULT,T</p> <p>YELLOW,SMALL,STRETCH,ADULT,T</p> <p>YELLOW,SMALL,STRETCH,CHILD,F</p> <p>I would like to remove everything after the last comma.. Note that I could have more than one character after the last comma. How can I do that?</p> <p>Thanks</p>
python
[7]
2,369,313
2,369,314
update command not working in gridview
<p>my code for update command:</p> <pre><code>public void update(name,email,phone) { using {sqlconnection con=new sqlconnection("some connection source")) { con.open(); string str = "UPDATE register SET name = @name,email = @email WHERE phone = "@phone"; using(sqlcommand cmd=new sqlcommand(str,con)) { cmd.commandtype=commandtype.text; cmd.parameters.addwithvalue("@name",name); cmd.parameters.addwithvalue("@email",email); cmd.parameters.addwithvalue("@phone",phone); cmd.executenonquery(); } } } </code></pre> <p>and my row updating event is this:</p> <pre><code>string name = ((TextBox)GridView1.Rows[e.RowIndex].Cells[1].Controls[0]).Text; string email = ((TextBox)GridView1.Rows[e.RowIndex].Cells[2].Controls[0]).Text; int phone = Convert.ToInt32(GridView1.Rows[e.RowIndex].Cells[3].Text); update(name, email, phone); GridView1.EditIndex = -1; bindgridview(); </code></pre> <p>In my table phone is the primary key, when I press update button its not firing no change nothing. Can anyone see my code and tell me where I did wrong</p>
asp.net
[9]
713,414
713,415
Scaling up an image
<p>This does not segment fault, but it is not reading the pixels of the "original" file.</p> <pre><code>Image Image::scaleUp(int numTimes) const { Image newImage(width*numTimes, height*numTimes); newImage.createImage(width*numTimes, height*numTimes); for (int x = 0; x &lt; width; x++) { for (int y = 0; y &lt; height; y++) { for(int inner_x = 0; inner_x &lt; numTimes; inner_x++){ for (int inner_y = 0; inner_y &lt; numTimes; inner_y++){ newImage.pixelData[x*numTimes+inner_x][y*numTimes+inner_y] = pixelData[x][y]; } } } } return newImage; } </code></pre> <p>Solved now * (*except my image comes out in b/w)</p>
c++
[6]
1,905,500
1,905,501
C++ Circular Construction Issue
<p>I am having trouble with an assignment. I have a class called Grid and Record. Record is Grid that stores how many times each position in a Grid has been accessed. Grid must contain a data member of type Record that can store whenever a change is made to Grid. I've managed to avoid a circular dependancy, but I seem to have a problem with a "circular construction" leading to a stack overflow. Calling the Grid constructor makes a Record, which creates a Grid, which tries to make another Record and so on. My first thought was to make Grid's Record data member a pointer which I initialize to NULL, then actually create the Record object outside of the constructor, however the assignment specifically says Grid's Record data member must be of type Record, not a pointer to a Record. I am also not allowed to give Record a default constructor, so I'm guessing my implementation is wrong. Any suggestions for how I can solve this problem?</p> <pre><code>Record::Record(int rows, int cols) : grid(new Grid(rows, cols)) {}; Grid::Grid(int rows, int cols) : record(new Record(rows, cols)) {}; </code></pre>
c++
[6]
3,777,745
3,777,746
What can be done when data in a table is very large?
<p>What can be done to handle data in tables that are extremely large?</p>
java
[1]
5,371,397
5,371,398
Which of the following performed to fully debug an asp.net application running on same machine as a debugger
<p>Which of the following performed to fully debug an asp.net application running on same machine as a debugger</p> <p>1.Enable Debug information in the .net Asssembly 2.Setting Debug Attribute of the compilation element to true in the web.config file. 3.Enabling asp.net debugging in the IIS Metabase.</p>
asp.net
[9]
2,794,074
2,794,075
Ways of comparing Text Content between HTML Elements
<p>As the title says, I am looking for a way of comparing the Text content of an HTML Element with another HTML Elements's Text content and only if they are identical, alert a message. Any thoughts? Greatly appreciate it! (Posted with code): For example, I can't equalize the remItem's content with headElms[u]'s content.</p> <pre><code>else if (obj.type == 'checkbox' &amp;&amp; obj.checked == false) { var subPal = document.getElementById('submissionPanel'); var remItem = obj.parentNode.parentNode.childNodes[1].textContent; alert("You have disselected "+remItem); for (var j=0; j &lt; checkSum.length; j++) { if (remItem == checkSum[j]) { alert("System found a match: "+checkSum[j]+" and deleted it!"); checkSum.splice(j,1); } else { //alert("There were no matches in the search!"); } } alert("Next are..."); alert("This is the checkSum: "+checkSum); alert("Worked!!!"); var headElms = subPal.getElementsByTagName('h3'); alert("We found "+headElms.length+" elements!"); for (var u=0; u &lt; headElms.length; u++){ alert("YES!!"); if (remItem == headElms[u].textContent) { alert("System found a matching element "+headElms[u].textContent+" and deleted it!"); } else { alert("NO!!"); alert("This didn't work!"); } } } </code></pre>
javascript
[3]
3,033,851
3,033,852
"UnConsting" const value via pointer
<p>First, sorry for possible question redundancy.</p> <p>Doing some little experiments with C/C++ pointers in GCC I encountered this somewhat weird behaviour when bypassing constantness of value at the pointer address.</p> <pre><code>#include &lt;iostream&gt; int main() { using namespace std; const double number = 100; //bypassing constantess of pointed-to value double * pointer_to_value = (double *) &amp;number; *pointer_to_value += 200; cout &lt;&lt; "Adress of number: " &lt;&lt; &amp;number &lt;&lt; "\tValue of number: " &lt;&lt; number &lt;&lt; endl &lt;&lt; " Pointer value: " &lt;&lt; pointer_to_value &lt;&lt; "\tDereferencing pointer: " &lt;&lt; *pointer_to_value; return 0; } </code></pre> <p>I would expect both form of checking the value yielding same results. Location of value is same in both cases. Program generates following output, however:</p> <p><em>Adress of number: 0x22ff30 Value of number: <strong>100</strong> Pointer value: 0x22ff30 Dereferencing pointer: <strong>300</em></strong></p> <p>Anyone capable of explaining? Thanks in advance.</p>
c++
[6]
702,437
702,438
Detecting a particular string value from a file, Java
<p>I'm trying to detect a particular string value in an external txt file. In this case, I am trying to detect %%.</p> <pre><code>public void read(){ while(x.hasNext()){ String a = x.next(); System.out.println(a); if(a == "%%"){ System.out.println("Found the end"); } else{ System.out.println("No end"); } } } </code></pre> <p>It is reading x correctly because it prints out the words from the file, but it says "No end" after every word, even the "%%". I'm sure I am making some dumb mistake somewhere, I just can't find it. x looks like this: apple orange %% grapes. Any help with this would be appreciated.</p>
java
[1]
4,790,059
4,790,060
How to make only limited letters can be typed into <input type="text" /> with jQuery?
<p>For example,to allow only digital numbers to be typed in:</p> <pre><code>&lt;input type="text" id="target" /&gt; </code></pre>
jquery
[5]
1,437,840
1,437,841
Check where request came from
<p>on the site when an image is required the link is like this</p> <pre><code>&lt;img src="getimage.php?id=&lt;?php echo $name ?&gt;" " width="280px" height="70px"&gt; </code></pre> <p>Then on getimage.php it gets the id and from that finds the right picture and displays it.</p> <pre><code>$id = $_GET['id']; </code></pre> <p>This works perfectly. How would I find out where the request came from. So on which page this line below was on </p> <pre><code>&lt;img src="getimage.php?id=&lt;?php echo $name ?&gt;" "width="280px" height="70px"&gt; </code></pre> <p>So ultimately I can know if the image requested is for index.php or about.php etc</p> <p>Thanks</p>
php
[2]
12,149
12,150
Return by reference or create a typical setter/getter?
<p>I was wondering about good practices in C++, and I was facing the problem of making a getter/setter for a class member.</p> <p>So, why don't simply return the member by reference so this way I can modify or access its value to read it? Specifically, this is my code:</p> <pre><code>class Chest : public GameObject { public: Chest(); ~Chest(); static int&amp; num_chests(); private: static int num_chests_; }; </code></pre> <p>Is this a bad practice? Should I use these instead?</p> <pre><code>class Chest : public GameObject { public: Chest(); ~Chest(); static int num_chests(); static void set_num_chests(int num_chests); private: static int num_chests_; }; </code></pre>
c++
[6]
3,674,480
3,674,481
Why do we use rt.jar in a java project?
<p>What is the necessity of rt.jar ??</p>
java
[1]
1,994,316
1,994,317
How does "until(-- p ---> second < 0)" loop until a non-positive value in found
<p>How does this code find a non-positive value?</p> <pre><code>#include &lt;map&gt; #include &lt;cstdio&gt; #define until(cond) while(!(cond)) using namespace std; int main() { // initialization map&lt;int,int&gt; second; int i=10; int testme[10]={4,3,1,-3,7,-10,33,8,4,14}; while (i --&gt; 0) second[i]=testme[i]; // find the first non-positive value in second map&lt;int,int&gt;::reverse_iterator p = --second.rend(); do { printf("Is %d non-positive?\n",second[++i]); } until(-- p ---&gt; second &lt; 0); // "second &lt; 0" to check if the value in second is non-positive printf("Yes it is!\n"); } </code></pre> <p>The output is:</p> <pre><code>Is 4 non-positive? Is 3 non-positive? Is 1 non-positive? Is -3 non-positive? Yes it is! </code></pre> <p>So how does the "second &lt; 0" string check for a non-positive value?</p>
c++
[6]
1,356,717
1,356,718
Javascript to image cycle
<p>Simple request, but I don't know how to do it. I've got a series of 10 images (image0.gif, image1.gif image2.gif etc...) that need to change to the next image in the sequence (cycling around after 9) when another image is pressed. This is what I have so far...</p> <pre><code> &lt;html&gt; &lt;head&gt;&lt;/head&gt; &lt;body bgcolor="#808080"&gt; &lt;script type="text/javascript"&gt; var c = 0; function preload(img) { var a = new Image(); a.src = img; return a; } if (needed) { time0 = preload("image0.gif"); time1 = preload("image1.gif"); time2 = preload("image2.gif"); time3 = preload("image3.gif"); time4 = preload("image4.gif"); time5 = preload("image5.gif"); time6 = preload("image6.gif"); time7 = preload("image7.gif"); time8 = preload("image8.gif"); time9 = preload("image9.gif"); } function clickme() { // update image c += 1; // alert(c) } &lt;/script&gt; &lt;div align="center"&gt; &lt;center&gt; &lt;img src="images/image0.gif" width="20" height="55" name="time0"&gt; &lt;a href="#" onMouseDown="return clickme()"&gt; &lt;img src="images/button.gif" border="0" width="96" height="55"&gt; &lt;/a&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/center&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
javascript
[3]
20,067
20,068
New runat="server" div element on aspx, does it require compiling?
<p>A new div element with a runat="server" property added to an ASP.NET presentation control does not required compilation to become active, but can anyone explain why this works without a rebuild? If you were to perform a rebuild would the assemblies contain any new information?</p> <p>I have a fix for a current project which involves the addition of a new runat="server" div element and I need to know if I can deploy this fix without new assemblies. I know it will work, but I need to know the technical differences (if any) between deploying just the aspx files and deploying the aspx files with a rebuilt dll.</p> <p>Does anyone know what tools I could use to examine assemblies in this level of detail and perform side-by-side comparisons to identify minor alterations in their content?</p>
asp.net
[9]
3,948,785
3,948,786
Jquery animation effect question
<p>I need some help on this on how can I animate the following:<br><br> If <strong>box1</strong> done fading in 2000ms then that is the time to start animate the <strong>box2</strong> the <strong>box3</strong> and <strong>box4</strong></p> <pre> $(document).ready(function(){ $('#box1').fadeIn(2000); $('#box2').fadeIn(2000); $('#box3').fadeIn(2000); $('#box4').fadeIn(2000); }); </pre> <p>How can i do this, or give me some link. I am noob in jquery<br><br> <strong>Thank you all</strong></p>
jquery
[5]
511,837
511,838
How to cancel the keyboard in UISearchbar?
<p>I'm using <code>UISearchBar</code> in my application and it serves as both an edit field as well as a search. So when I want to disappear the keyboard I have to use cancel button in UISearchBar but I can't have that cancel button on screen, so how could T make keyboard disappear when not used without using cancel button. Please help me as i'm new to iPhone application development.</p> <p>Thanks in advance!</p>
iphone
[8]
4,826,262
4,826,263
Check if the string contains all inputs on the list
<p>I want to be able to check if the string contains all the values held in the list; So it will only give you a 'correct answer' if you have all the 'key words' from the list in your answer. Heres something i tired which half fails;(Doesn't check for all the arrays, will accept just one). Code i tired:</p> <pre><code> foreach (String s in KeyWords) { if (textBox1.Text.Contains(s)) { correct += 1; MessageBox.Show("Correct!"); LoadUp(); } else { incorrect += 1; MessageBox.Show("Incorrect."); LoadUp(); } } </code></pre> <p>Essentially what i want to do is:</p> <blockquote> <p>Question: What is the definition of Psychology?</p> </blockquote> <p>Key words in arraylist: <strong>study,mental process,behaviour,humans</strong></p> <blockquote> <p>Answer: Psychology is the <strong>study</strong> of <strong>mental process</strong> and <strong>behaviour</strong> of <strong>humans</strong></p> </blockquote> <p>Now if and ONLY if the answer above contains all key words will my code accept the answer. I hope i have been clear with this.</p> <p><strong>Edit:</strong> Thank you all for your help. All answers have been voted up and i thank everyone for quick answers. I voted up the answer that can be easily adapted to any code. :)</p>
c#
[0]
4,402,783
4,402,784
Comparison amongst characters
<p>Suppose I have a function which takes in two values and returns one value, as per the rule:</p> <pre><code>(x,y) should return y (y,z) should return z (z,x) should return x (y,x) should return y (z,y) should return z (x,z) should return x </code></pre> <p>How to I store these cases? The ordering of the parameters do not matter. I do not want to use a series of nested if else statements</p>
java
[1]
2,841,783
2,841,784
How to get file extension from Save file dialog?
<p>I would like to be able to save image according to extension that is entered in the save file dialog. I have found out that simply entering e.g. "JPG" does not cause the Save method to use this format of course. Parsing the extension and then using e.g. switch and setting correct format sounds a bit ackward to me. Or there is no better way?</p>
c#
[0]
2,514,354
2,514,355
Server.MapPath isn't pointing to the actual server path when deployed
<p>I put the server.MapPath code in ASP.NET VB code behind.</p> <p>On my laptop i compile and build. However when i upload my web application to the actual server. I received error where the link is still referencing the laptop link.</p> <p>How can i solve this issue?</p> <p>My code is</p> <pre><code>Server.MapPath("./scorecardsheet/db.xls") </code></pre> <p>Actual server link is <code>c:\Inetpub\vhosts\xxx.com\httpdocs\xxx\scorecardsheet\db.xls</code></p> <p>but when i run the page on the server it shows the link of my development platform as <code>c:\user\jerry\visual studio 2010\projects\xxx\xxx\scorecardsheet\db.xls</code></p>
asp.net
[9]
1,897,436
1,897,437
Delete first instance of string with PHP
<p>How do I delete the first instance of a substring in another string with PHP? Thanks.</p>
php
[2]
3,993,045
3,993,046
How add elements (key =>value) to an empty array?
<p>How add elements (key =>value) to an empty array with a loop? To build Json data for AJAX response. I've tried array_push. But not works</p> <pre><code>$arr = array(); foreach ($result as $row) { array_push($arr, $row-&gt;key =&gt; $row-&gt;value); } $data['message'] = json_encode($arr); </code></pre>
php
[2]
1,936,624
1,936,625
php dynamic dropdown box content
<p>I've got two data tables like below.</p> <p>Table 1: </p> <pre><code>-------------------- sbstart sbend totsb -------------------- 200 205 6 </code></pre> <p>Table 2:</p> <pre><code>chkNo ------ 201 203 </code></pre> <p>I have got a dropdown box created dynamically which contains table 1 information which is all the responses from 200 to 205. In other words that dropdown has 200,201,202...205. What I now need is to exclude the numbers in table 2 once the dropdown box is created. For instance then the dropdown should have only 200,2004 and 2005 when it is displayed.</p> <p>Here is the code I've done to get all the responses between start and end number as per table 1. Can someone please tell me how do I exclude the table 2 numbers once the dropdown is created. Thanks.</p> <pre><code> $con=mysql_connect('localhost','root') or die ("Server connection failure!"); $db=mysql_select_db('regional_data',$con) or die ("Couldn't connect the database"); $SQLx="SELECT * FROM table1"; $runx=mysql_query($SQLx,$con) or die ("SQL Error"); $norx=mysql_num_rows($runx); while ($rec = mysql_fetch_array($runx)) { for($i=$rec['sbstart']; $i&lt;=$rec['sbend']; $i++) { echo "&lt;option id='options' value='$i'&gt;$i&lt;br&gt;&lt;/option&gt;"; } } </code></pre>
php
[2]
3,374,888
3,374,889
Escape Semicolon in PHP?
<p>I've created a database where I have product attributes separated with semicolons <code>;</code>. The reason I chose this is it's incredibly unlikely come up naturally as part of one of the specifications.</p> <p>I was wishing to do this:</p> <pre><code>&lt;ul&gt; &lt;li&gt;&lt;?php str_replace(';','&lt;/li&gt;&lt;li&gt;',$row['specifications']); ?&gt;&lt;/li&gt; &lt;/ul&gt; </code></pre> <p>It would have created a nice unordered list. However, the semicolon is seen as part of the PHP code itself rather than part of the <code>str_replace</code> function. It's not being escaped with the normal backslash method.</p> <p>Is there any way of escaping the semicolon character in this function or have I just been a bit daft in choosing the semicolon and should've chosen something else?!</p> <p>-- edit --</p> <p>Sorry, my mistake, it does work. I'd missed my close bracket after ['specifications'].</p> <p>Thanks for the answers, though!</p>
php
[2]
1,217,265
1,217,266
How to keep an alarm program alive
<p>I am writing an alarm program for android and am very happy with it so far. But I have a big concern about how to make sure it keeps running constantly. I.e. I don't want the OS to kill it to free up memory (I'd like the OS to kill other apps first) and I want to ensure that the program starts up again if the user powers down and up again. How can I achieve this?</p>
android
[4]
3,589,360
3,589,361
Unexpected T_String
<pre><code>unset($item_row); $item_row = array(); if ($row[1] == "BCP-Prod1"){ $row[1] = "BCP-Product1"; $item_row['nid'] = 71; $item_row['title'] = 'Product1 - This is the title'; } elseif ($row[1] == "BCP-SILLYNECK"){ $row[1] = "BCP-Prod2"; $item_row['nid'] = 77; $item_row['title'] = 'Products2 - This is the title for 2'; } </code></pre> <p>The error I am getting is:</p> <blockquote> <p>Parse error: parse error, unexpected T_STRING in import_orders.php on line 89</p> </blockquote> <p>Line 89 is <code>$item_row['nid'] = 71;</code> I must be looking over something cause I am not seeing what is causing this?</p>
php
[2]
2,188,195
2,188,196
Why is 0 == "" true in JavaScript
<p>Why is <code>0 == ""</code> true in JavaScript? I have found a <a href="http://stackoverflow.com/questions/4567393/why-do-alert0-and-alertfalse-0-both-output-true-in-javascript">similar post here</a>, but why is a number 0 similar an empty string? Of course, <code>0 === ""</code> is false.</p>
javascript
[3]
4,759,179
4,759,180
Etc/GMT+(offset) only providing GMT in PHP
<p>According to PHP, the timezone in the format <code>Etc/GMT+(offset)</code> is a <a href="http://www.php.net/manual/en/timezones.others.php" rel="nofollow">valid timezone</a>. Based on that, I would have assumes that this code would output a series of different timezomes:</p> <pre><code>$start_date = 'Dec 16, 2011'; $start_time = '09:45:00'; #$utime_zone = 'GMT'; &lt;-- switching to GMT works! $utime_zone = 'Etc/GMT'; for($i = -12; $i &lt;= 12; $i++){ $curr = ($i &gt;= 0)?'+'.$i: $i; $str = ($start_date . " " . $start_time . " " . $utime_zone.$curr); echo $str . ' = ' . strtotime($str).PHP_EOL; } </code></pre> <p>Unfortunately, the strtotime calls are all ignoring the timezone completely.</p> <p>The output:<br /> <code>Dec 16, 2011 09:45:00 Etc/GMT-12 = 1324028700</code><br /> <code>Dec 16, 2011 09:45:00 Etc/GMT-11 = 1324028700</code><br /> <code>Dec 16, 2011 09:45:00 Etc/GMT-10 = 1324028700</code><br /> <code>...you get the idea.</code></p> <p>Clearly I have made some assumption about this, but is there an easy way to convert from <code>Etc/GMT+(offset)</code> to a GMT timestamp?</p>
php
[2]
3,317,595
3,317,596
javascript in html head, innerhtml not working?
<pre><code> &lt;html&gt; &lt;head&gt; &lt;script type="text/javascript"&gt; document.getElementById("eee").innerHTML = "7777"; &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;p id="eee"&gt;aa&lt;/p&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>why does the innerHTML not work in the head, but it does work in the body? Excuse the beginners question but last time i used javascript a year ago this was not a problem at all.</p>
javascript
[3]
4,778,487
4,778,488
Python condense if/else to one line?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/394809/python-ternary-operator">Python Ternary Operator</a><br> <a href="http://stackoverflow.com/questions/2802726/putting-a-simple-if-then-statement-on-one-line">Putting a simple if-then statement on one line</a> </p> </blockquote> <p>Is there a way to compress an if/else statement to one line in Python? I oftentimes see all sorts of shortcuts and suspect it can apply here too.</p>
python
[7]
2,033,401
2,033,402
How can I copy a python class property?
<p>In an attempt to discover the boundaries of Python as a language I'm exploring whether it is possible to go further with information hiding than the convention of using a leading underscore to denote 'private' implementation details.</p> <p>I have managed to achieve some additional level of privacy of fields and methods using code such as this to copy 'public' stuff from a locally defined class:</p> <pre><code>from __future__ import print_function class Dog(object): def __init__(self): class Guts(object): def __init__(self): self._dog_sound = "woof" self._repeat = 1 def _make_sound(self): for _ in range(self._repeat): print(self._dog_sound) def get_repeat(self): return self._repeat def set_repeat(self, value): self._repeat = value @property def repeat(self): return self._repeat @repeat.setter def repeat(self, value): self._repeat = value def speak(self): self._make_sound() guts = Guts() # Make public methods self.speak = guts.speak self.set_repeat = guts.set_repeat self.get_repeat = guts.get_repeat dog = Dog() print("Speak once:") dog.speak() print("Speak twice:") dog.set_repeat(2) dog.speak() </code></pre> <p>However, I'm struggling to find a way to do the same for the property setter and getter.</p> <p>I want to be able to write code like this:</p> <pre><code>print("Speak thrice:") dog.repeat = 3 dog.speak() </code></pre> <p>and for it to actually print 'woof' three times.</p> <p>I've tried all of the following in <code>Dog.__init__</code>, none of which blow up, but neither do they seem to have any effect:</p> <pre><code>Dog.repeat = guts.repeat self.repeat = guts.repeat Dog.repeat = Guts.repeat self.repeat = Guts.repeat self.repeat = property(Guts.repeat.getter, Guts.repeat.setter) self.repeat = property(Guts.repeat.fget, Guts.repeat.fset) </code></pre>
python
[7]
5,369,090
5,369,091
How to maximize performance in Python when doing many I/O bound operations?
<p>I have a situation where I'm downloading a lot of files. Right now everything runs on one main Python thread, and downloads as many as 3000 files every few minutes. The problem is that the time it takes to do this is too long. I realize Python has no true multi-threading, but is there a better way of doing this? I was thinking of launching multiple threads since the I/O bound operations should not require access to the global interpreter lock, but perhaps I misunderstand that concept. </p>
python
[7]
254,173
254,174
Create manual versions
<p>Iam planning to create an app, and not to publish it at the google market. i want the users to update thire app once in a while when an updates will be rlsd via server(let's not get into the idea how i gonna do this)... so for this i need to give to each app some ID, so i know that that user gotta update his app, and not new installation (i wanna avoid the case the user will have two versions of the app).. and ofcourse install the app to new users. how could i sign those apps with version when i rls an update manually? mybe some other idea?</p> <p>thanks, ray.</p>
android
[4]