Unnamed: 0
int64
65
6.03M
Id
int64
66
6.03M
Title
stringlengths
10
191
input
stringlengths
23
4.18k
output
stringclasses
10 values
Tag_Number
stringclasses
10 values
3,888,927
3,888,928
Is there a javascript equivalent of python's __getattr__ method?
<p>In python you can define a object having <code>__getattr__(self,key)</code> method to handle all unknown attributes to be solvable in programmatic manner, but in javascript you can only define getters and setters for pre-defined attributes. Is there a generic way of getting the former thing done also in javascript?</p> <p>Sample code would be smth like:</p> <pre><code>function X() {}; X.prototype={ __getattr__:function(attrname) { return "Value for attribute '"+attrname+"'"; } } x=new X() alert(x.lskdjoau); // produces message: "Value of attribute 'lskdjoau'" </code></pre> <p>Key point is getting value of attribute programmatically depending on the name of the attribute. Pre-setting attribute does not help because during init there is no information what attributes might be requested.</p>
javascript
[3]
4,279,821
4,279,822
Javascript: Can‘t get document.getelementbyid to work
<p>I found many questions concerning form elements that are null but I simply can‘t get this to work.</p> <p>It works in every browser but when it‘s embedded in Wordpress it stops working in Firefox. The Firefox-Console says I should use document.getelementbyid but in every way I try it, Firefox says the form is null or that "myform is not defined".</p>
javascript
[3]
4,615,318
4,615,319
TimeStamp Standard PHP
<p>I am working on creating a log file where log details including timestamp should be written to the log file. But is there any standard timestamp function which I can use in the php code which does not show any sort of errors like "You cannot rely on SYstem's timezone' etc . Thanks</p>
php
[2]
3,514,335
3,514,336
How do I generate totally a random number at a time?
<p>I want to create 3 random number at a time (simultaneously). However, they returned me the same numbers at a time even though they are actually random. Example:</p> <pre><code>------------------------ Variable: A B C ------------------------ Time 1 : 5 5 5 Time 2 : 3 3 3 Time 3 : 9 9 9 ------------------------ </code></pre> <p>They suppose to be different numbers at all. From the observation, I can see that my code can only pick a random number at a time (interval 1 second). Here is my generator code that I'm using:</p> <pre><code>unsigned int CMain::GenerateRandom(int min, int max) { srand((unsigned)time(0)); unsigned int random_integer; int lowest = min, highest = max; int range = (highest - lowest) + 1; random_integer = lowest + int(range * rand() / (RAND_MAX + 1.0)); return random_integer; } </code></pre> <p>How could I generate a totally random numbers at a time? Please help.</p> <p>Thank you.</p>
c++
[6]
2,912,120
2,912,121
Trigger different event after changing class - Jquery
<p>On my html page, there is a button which initially have the class name "show-update". After clicking on that button, that button will be changed to another class name and i want to set another clicking event to that particular class. However, i am still not successful to do that. Is there anyone know how to fix it ? I am using jquery 1.72</p> <p>This is my code <a href="http://jsfiddle.net/dwGCH/1/" rel="nofollow">http://jsfiddle.net/dwGCH/1/</a></p>
jquery
[5]
5,352,303
5,352,304
PHP function scope
<p>I know this is kind of a hacky thing I'm trying here, but I'm wondering if this is even possible. is there anyway I can access the <code>$x</code> variable in the following code, without passing arguments?</p> <pre><code>function foo() { $x = 1; return bar(); } function bar() { //get $x from foo here somehow? return $x ? 'stuff' : 'other stuff'; } </code></pre>
php
[2]
255,136
255,137
How to calculate time between key pressed
<p>I wanna calculate the time between key 37 and 39 pressed. This is the left and right key.</p> <p>So the user would press the two keys and i must calculate between each 2 key presses how long each gap was.</p>
jquery
[5]
3,233,479
3,233,480
what's the best to use to android with xml
<p>I'm working in android with web services I just confused between the xml parser way what the diffrence between the httpclient and the xmlpullparser SAXParser and what's the best to use with xml webservices for uploading updating and parsing the data ?? </p>
android
[4]
3,735,220
3,735,221
check the if DOM has class name attached to it
<p>I want to check if a Dom has class value attached to it.. Since that DOM will be assigned a random class value dynamically, I will not know the class name specifically, so is it possible to check if it has a class element attached to irrespective of its class name.</p>
jquery
[5]
337,603
337,604
PHP/HTML echo a variable in a div
<p>I have a div which works fine</p> <pre><code> &lt;div id="fb-root"&gt;&lt;/div&gt; &lt;fb:like href="&lt;?php echo $link; ?&gt;" send="true" width="450" show_faces="true" font=""&gt; &lt;/fb:like&gt; </code></pre> <p>If I try to use an echo, I don't get the value of $link when I do this.</p> <pre><code>echo '&lt;div id="fb-root"&gt;&lt;/div&gt; &lt;fb:like href="&lt;?php echo $link; ?&gt;" send="true" width="450" show_faces="true" font=""&gt; &lt;/fb:like&gt;'; </code></pre> <p>likewise this one too. i cannot get the $link.</p> <pre><code>echo '&lt;iframe src="http://www.facebook.com/plugins/like.php?app_id=208015255907895&amp;amp;href="',$link,'"&amp;amp;send=true&amp;amp;layout=button_count&amp;amp;width=50&amp;amp;show_faces=true&amp;amp;action=like&amp;amp;colorscheme=light&amp;amp;font=trebuchet+ms&amp;amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:50px; height:21px;" allowTransparency="true"&gt;&lt;/iframe&gt; ' </code></pre> <p>Any help?</p>
php
[2]
1,715,840
1,715,841
Serial Number Checker
<p>I am trying to create a serial number checker.</p> <p>Serial Numbers are in ranges<br> A87594 - A92778<br> AB34534 - AC23405<br> B23933 - C344444</p> <p>I was able to get the numbers to work using <strong>range()</strong> for the first serial number example, I'm guessing I need to use <strong>explode()</strong> but I wasn't sure how to explode the letters into a variable and the numbers into a seperate variable.</p> <pre><code>if($_POST['submit']) { $snum = $_POST['serial_number']; // 1952 $jan01_jan07 = range(87594, 92478); if (in_array($snum, $jan01_jan07)) { echo 'You have a 1952 Widget'; } else { echo 'Your serial number is unknown'; } } </code></pre>
php
[2]
1,288,168
1,288,169
Adding multiple DIV elements using functions with JavaScript
<p>I am kind of new to JS and that is why I am asking for some help with this. I want to create multiple nested div elements like this: </p> <pre><code>&lt;div&gt; &lt;div&gt; &lt;div&gt; &lt;/div&gt; &lt;div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>I already did create them but my mentor at work wants me to use functions so that it would make the code more readable.</p> <p>I already have tried to create multiple functions for every each element that is created, but he told me that he doesn't like it and want's me to try another way. So that is why I am asking for some help. I already tried this (it is just a sample don't have permission to show actual code... company rules):</p> <pre><code> function firstContainerCreator(){ firstContainer= doc.createElement("div"); } function innerContainerCreator(){ innerContainer= doc.createElement("div"); } function innerContainer_imgCreator(){ innerContainer_img= doc.createElement("div"); } function innerContainer_paragraphCreator(){ innerContainer_paragraph= doc.createElement("div"); } </code></pre> <p>Any help is appreciated.</p>
javascript
[3]
3,405,587
3,405,588
Max similarity of two character dictionaries?
<p>Say I have a python dictionary:</p> <pre><code>d = {"a":1, "b":2} </code></pre> <p>this represents the number of occurrences a character has in a string. So the above dictionary could generate a string of "abb", "bab", or "bba".</p> <p>The Max similarity between two dictionaries is a ratio >= 0 and &lt;= 1 that describes how similar the two most similarly generated strings are.</p> <p>For example,</p> <pre><code>d1 = {"a":1, "b":2} d2 = {"c": 3} d3 = {"a":1, "d":2} max_sim(d1, d2) # equals to 0.0 because no indexes # of an arrangement of ccc matches any indexes of an arrangement of abb max_sim(d1, d3) # equals to 0.333 because an arrangement of add matches # one out of three characters of an arrangement of abb # note that if we compared dda and abb, the similarity ratio would be 0.0 # but we always take into account the most similarly generated strings </code></pre> <p>How can I generate the max similarity of any two dictionaries (same length) simply by looking at the number of occurrences per character? i.e. simply analyze the dictionaries and not actually generate the strings and check the similarity ratio of each pair.</p> <p>Note: I'm using max_sim on dictionaries rather than strings because I've already looped through two strings to gather their dictionary data (in addition to something else). If I use max_sim on two strings (either the original strings or convert the dictionaries back to strings), I figure I'd be just doing redundant computation. So I'd appreciate it if the answer took two dictionaries as inputs.</p>
python
[7]
3,515,155
3,515,156
Want to animate splash screen in android
<p>I want to add fade in and fade out to splash screen after a few seconds of loading, is there any sample for doing this to my splash layout?</p>
android
[4]
2,704,681
2,704,682
Advice needed on VideoView Positioning
<p>I am looking for a bit of advice on how to approach this situation in Android:</p> <p>Let's say I have a video that can be broken up into 4 separate frames for each single main frame, IE.</p> <pre><code>xxxxxx|oooooo xxxxxx|oooooo xxxxxx|oooooo ————————————— yyyyyy|zzzzzz yyyyyy|zzzzzz yyyyyy|zzzzzz </code></pre> <p>(I apologize for the crappy diagram)...</p> <p>Now let's say I want to only display just one of those sub-frames at a time, and that is where I'm asking for the advise.</p> <p>I've thought of several approaches, but I don't think they'd work well, if at all:</p> <ol> <li><p>Using the drawing cache and manually setting an image frame-by-frame. This approach won't work at all on hardware accelerated devices with a SurfaceView (IE. VideoView), not to mention the processing required to create a multitude of Bitmaps would be hefty, cause lag, and would create a crappy user experience. So I've nixed that idea.</p></li> <li><p>Shifting the coordinates of the video within the VideoView itself to only display the desired portion. I think this may be the best approach I'm aware of, but I honestly don't know where to start this one. I figured I'd have to create my own custom VideoView, but I'm not sure how I would actually draw only portions of the video at a time.</p></li> </ol> <p>But yeah, does anyone have any advise or suggestions on how I should tackle this challenge?</p>
android
[4]
3,223,882
3,223,883
get return result after post to server (from iphone)
<p>I make iphone application, post parametes to JSP (test.jsp in server) from iphone. The following is my codes: </p> <pre><code>NSData *postData = [@"&amp;test=123&amp;field=456" dataUsingEncoding:NSUTF8StringEncoding]; NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]]; // Init and set fields of the URLRequest NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init]; [request setHTTPMethod:@"POST"]; [request setURL:[NSURL URLWithString:[NSString stringWithString:@"http://mydomain.com/test.jsp"]]]; [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"]; [request setValue:postLength forHTTPHeaderField:@"Content-Length"]; [request setHTTPBody:postData]; NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self]; if (connection) { // Return data of the request NSData *receivedData = [[NSMutableData data] retain]; } [request release]; </code></pre> <p>But my problem is: I can not get return result from JSP server. How I can setup in JSP to get return result in iPhone? and in iPhone too?</p> <p>Thank all</p>
iphone
[8]
329,094
329,095
Site hacked, who wants to figure out what this encoded string says (ROT13, eval, base64_decode, and gzinflate used)?
<p>In several files, I found injected code in my PHP files. I attempted to Pastebin the code, but Pastebin actually wouldn't accept the code. I tried various Pastebin alternatives as well, none of them would accept the code as-is, not even StackOverflow.</p> <p>So what I've done is uploaded the to my own personal server and am hosting it from a *.txt file. If someone knows a better way, please let me know. I know it seems fishy (at least, my actions seem fishy even to me) and I apologize for that.</p> <p>Also, there are three "paragraphs" of code, each paragraph was found on a different page, injected at the top of all 3. The first block of code is rather small, only about 5 or so lines after wordwrap. The other two blocks of code are quite lengthy, and in the 3rd block of code exists a 4th inline encoded string.</p> <p>The injected code:</p> <p><a href="http://184.172.138.95/~smgwebd/code.txt" rel="nofollow">http://184.172.138.95/~smgwebd/code.txt</a></p>
php
[2]
615,811
615,812
Get X and Y cordinate Of view
<p>I have one UITableView in My View.The name of my UITableView is tblTask.<br/> I am using touchesBegan method to get the x and y cordinate of my view.<br/></p> <pre><code>-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; CGPoint location = [touch locationInView:self.view]; NSLog(@"point........ %f .. %f",location.x,location.y); } </code></pre> <p>But when I begin the touch event from the tbltask. It does not return the location.x and location.y even if tbltask is the subview of the main view. <br/><br/> I tried to disable the scrollview of the table also but nothing happen. <br/> when i set this.</p> <pre><code>tbltask.userInteractionEnabled=NO; </code></pre> <p>then it will give the cordinate but i want the cordinate of view even if tbltask interaction is enabled.<br/><br/> so please help me on this.</p>
iphone
[8]
5,147,749
5,147,750
How do I make a python script wait for sometime?
<p>I'm relatively new to python and I have written a single python script which does the following:</p> <ol> <li>It does some operation and writes the details to a text file(say a.txt)<br/></li> <li>Once the txt file(a.file) is written, the same file is read to do some operations.</li> </ol> <p>The problem I face is once the file(a.txt) is written and same is read, the contents are not read.</p> <p>I use <code>time.sleep()</code> after the txt file(a.txt) is written and then proceeded with reading the same.</p> <p>But whats happening is the script is stopping it's execution for the time period mentioned in the sleep method and the txt file is not read.</p> <p>I need a scenario where the same script must write to a text file and read instantly.</p> <p>Could someone help me please? Thanks in advance.</p>
python
[7]
5,043,833
5,043,834
Calculate Remote Image File Size Using PHP
<p>How can I find the file size of an image on a remote server? On the local machine, I can use <code>filesize()</code>, but I want to find the size without downloading the image.</p>
php
[2]
2,667,697
2,667,698
"Attribute hash", what's that?
<p>I am reading <a href="http://documentcloud.github.com/backbone/docs/backbone.html#section-28" rel="nofollow">the annotated source code of backbone.js</a> and it mentions "attribute hash". What is that?</p> <blockquote> <p>Set a hash of model attributes on the object, firing "change" unless you choose to silence it.</p> </blockquote> <p>My understanding is it is an object, array, etc, or does hash refers to any format in particular?</p>
javascript
[3]
3,234,884
3,234,885
Find and hide text using jQuery
<p>This, I thought, was a very simple query, but I seem to be getting lost in the find/hide code.</p> <p>To simplify:</p> <p>I may have something like this <code>&lt;h1 class="begin-page"&gt; TEST AREA&lt;/h1&gt;</code></p> <p>I want to find the text "<strong>TEST AREA</strong>" and hide it.</p> <p>How can I accomplish that via jquery?</p> <p>Thank you.</p>
jquery
[5]
5,985,082
5,985,083
How to programmatically determine installed audio applications on Android
<p>I'm trying to programmatically determine what audio applications are installed on an Android phone. I'm able to enumerate all the installed applications, but don't yet see a way to figure out which ones are capable of playing audio? What property of the application would have to queried to determine if is capable of playing audio?</p> <p>Thanks in advance.</p>
android
[4]
2,140,752
2,140,753
How do I Copy an Android Project to Make a Pro Version?
<p>I want to make a pro version of my app that is ad free and contains more features. I have tried copying the project and changing the class name and such but it doesn't want to run. So what I was wondering is if there is an easy way to archive this or do I have to go through it all and copy and paste each file and change paths and stuff.</p>
android
[4]
2,173,707
2,173,708
c++" fatal error C1083: Cannot open include file: 'blabla': No such file or directory" only in Release Build
<p>whenever I compile my project in the Release build I get this error:</p> <pre><code>Error 29 fatal error C1083: Cannot open include file: 'NX_Win32Wrapper.h': No such file or directory </code></pre> <p>I get another one just like this, just in a different file (the error complains about a different file). The file in the second error is whichever I included first (is on top of the include list), the same goes for the first error, but its right after:</p> <p>(this is the "main".cpp file,where main() is and GameV2 is my project name</p> <pre><code> #include "stdafx.h" #include "GameV2.h" </code></pre> <p>I know there is now code, but I think I'd have to post everything :P Do you have any suggestion what should I check?</p>
c++
[6]
2,019,771
2,019,772
jQuery: does using .html(html) replace current content
<p>When I do something like:</p> <pre> <code>$.post("update.php", {page: $(this).attr('data-page')}, function(success){ $("#dialog").html(html); } }); </code> </pre> <p>and I have a :</p> <pre><code>&lt;div id="dialog" style="display: block;"&gt; //a bunch of html in here, initially it's not empty &lt;/div&gt; </code></pre> <p>Then will that <code>$("#dialog").html(html);</code> replace all the bunch of html that initially we have or does it append to it?</p>
jquery
[5]
2,414,093
2,414,094
Passing Variables Into URL
<p>I am trying to ad the values from 2 form elements into a function and can get the first to add but can't work out the correct way to code for the second.</p> <pre><code>$(function() { $('#form_orderTracking').click(function(){ $('#CustomerDetails').load('TrackOrder1.asp?OrderID=' + $('#orderID').val()); }); }); </code></pre> <p>I am trying to add the value for the emailAddress field so that the url reads:</p> <pre><code>TrackOrder1?OrderID=123456&amp;EmailAddress=abc@123.com </code></pre>
jquery
[5]
1,445,059
1,445,060
JavaScript: 'foo' or foo {0="f", 1="o", 2="o"}`
<p>I have two fiddles that apply the code below, the only difference being that one uses console.log while the other uses alert to show the value of the variable myString. One fiddle alerts the string 'foo' while the other logs foo like this <code>foo {0="f", 1="o", 2="o"}</code> What accounts for this difference? </p> <pre><code> var myString = new String('foo'); // produces a String() object alert(myString);​ </code></pre> <p><a href="http://jsfiddle.net/mjmitche/UdYXZ/" rel="nofollow">http://jsfiddle.net/mjmitche/UdYXZ/</a></p> <p><a href="http://jsfiddle.net/javascriptenlightenment/XcfC5/" rel="nofollow">http://jsfiddle.net/javascriptenlightenment/XcfC5/</a></p>
javascript
[3]
4,109,564
4,109,565
difference between foreach()
<p>Is there any major difference between </p> <pre><code>foreach(){ } foreach(): endforeach; </code></pre>
php
[2]
5,597,669
5,597,670
C# code cannot understand
<p>I have a question, because I am a coder of c++, now I need read some c# code. This is a class in a namespace, what I do not understand is the last member; </p> <pre><code>public string FilePath { get { return this.filePath; } set { this.filePath = value; } } </code></pre> <p>I do not know it is a member variable or a member function. </p> <p>If see it as a member function, it should like </p> <pre><code>public string FilePath(***) { ****; } </code></pre> <p>but here it doesn't have a () similar parameter, what type of function is it?</p> <pre><code> class INIFileOperation { private string filePath; [DllImport("kernel32")] private static extern long WritePrivateProfileString(string section, string key, string val, string filePath); [DllImport("kernel32")] private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath); public string ReadAppPath() { string appPath = Path.GetDirectoryName(Application.ExecutablePath); return appPath + "\\Setting.ini"; } public INIFileOperation() { this.filePath = ReadAppPath(); } public void Write(string section, string key, string value) { WritePrivateProfileString(section, key, value.ToUpper(), this.filePath); } public string Read(string section, string key) { StringBuilder SB = new StringBuilder(255); int i = GetPrivateProfileString(section, key, "", SB, 255, this.filePath); return SB.ToString(); } public string FilePath { get { return this.filePath; } set { this.filePath = value; } } } </code></pre>
c#
[0]
4,601,566
4,601,567
Combobox item preview
<p>I have a combobox with items(paths of opened files with opendialog).</p> <p><img src="http://screenshotuploader.com/i/01/0k8n94fka.png" alt="Screenshot"></p> <p>How to show only files name in combobx preview?</p> <pre><code> OpenFileDialog openFileDialog1 = new OpenFileDialog(); openFileDialog1.Title = "Выбрать фаил для загрузки"; openFileDialog1.InitialDirectory = System.Environment.CurrentDirectory; openFileDialog1.Multiselect = true; if (openFileDialog1.ShowDialog() == DialogResult.OK) { foreach (String file in openFileDialog1.FileNames) { comboBox1.Items.Add(file); } } </code></pre>
c#
[0]
5,249,314
5,249,315
Strange sum problem
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/1458633/elegant-workaround-for-javascript-floating-point-number-problem">Elegant workaround for JavaScript floating point number problem</a> </p> </blockquote> <pre><code>var sum = 0; $('[id$=percentOfTotalEditor]').each( function () { var igEditor = $find(this.id); var value = igEditor.get_value(); sum += value; } ); </code></pre> <p>Then you'll see the magic:</p> <p>sum == 1.1, value == 0.1. But after sum += value, sum == 1.2000000000000001</p> <p>WTF!?</p>
javascript
[3]
3,837,200
3,837,201
how to use nspredicate for this?
<p>i am stuck with using nspredicate in the following code:</p> <pre><code>for (int i=0; i&lt;[nodes count]; i++) { NSMutableDictionary *dict=[nodes objectAtIndex:i]; NSInteger docid = [[dict objectForKey:@"docid"] integerValue]; NSString *strPred = [NSString stringWithFormat:@"docId == %i",docid]; [request setPredicate:[NSPredicate predicateWithFormat:strPred]]; NSArray* objects=[[context executeFetchRequest:request error:nil] retain]; NSPredicate *objCount = [NSPredicate predicateWithFormat:[objects count]]; if([objects count])//how do i reduce these if else block too using nsprdicate { [dict setObject:@"1" forKey:@"isbookthere"]; } else { [dict setObject:@"0" forKey:@"isbookthere"]; } [objects release]; [nodes replaceObjectAtIndex:i withObject:dict]; } </code></pre> <p>i have to remove the ifelse block too since, if the count goes to 4000 the the loop goes for those many iterations which cause problem,so inorder to reduce this risk i am suppose to use NSPredicate.</p>
iphone
[8]
1,687,223
1,687,224
@SuppressWarnings - Static Variable
<p>Which parameter <strong>@SuppressWarnings</strong> use to hide <strong>Warning(209.56): static variable Should be qualified by type name, javax.swing.ListSelectionModel, instead of by an expression</strong>?</p>
java
[1]
3,814,769
3,814,770
compile python .py file without executing
<p>Is there a way to compile a Python .py file from the command-line <strong>without</strong> executing it?</p> <p>I am working with an application that stores its python extensions in a non-standard path with limited permissions and I'd like to compile the files during installation. I don't need the overhead of Distutils.</p>
python
[7]
1,050,168
1,050,169
How do you add a current class to a li with jquery?
<p>I have the following code:</p> <pre><code> &lt;ul&gt; &lt;li class="tree"&gt; &lt;span&gt;&lt;a class="collapse" href="#"&gt;Collapse&lt;/a&gt;&lt;/span&gt; &lt;/li&gt; &lt;li class="tree"&gt; &lt;span&gt;&lt;a class="expand" href="#"&gt;Expand&lt;/a&gt;&lt;/span&gt; &lt;/li&gt; &lt;/ul&gt; </code></pre> <p>How can I add a class on the li to current when you click on the expand link and then take off the current when I click on the collapse in jquery?</p>
jquery
[5]
4,785,543
4,785,544
python and xml integration
<p>How do I produce XML from Python?</p> <p>I built a program for keystroke detection integrated with open office and other softwares and i want the output of the program to be stored in an XML file?</p> <p>my program detects the keys stroked in an open office, ms office software. i want the outpu to be directly stored in an XML file</p>
python
[7]
3,815,196
3,815,197
rewrite two variable with RewriteRule
<p>I have a code like this:</p> <pre><code> echo " &lt;td width='57%' height='126' class='bord' &gt;&lt;a href='$category_name-$id.htm' class='title_style'&gt;" . $title . "&lt;/a&gt;&lt;br /&gt; "; </code></pre> <p>So, $category_name is the name of categories from database. So it changes!</p> <p>I need to rewrite it using RewriteRule. I've tried something like this</p> <pre><code> Options +FollowSymlinks RewriteEngine on RewriteRule ^([a-zA-Z0-9-]+)-([0-9]+)\.htm$ classified.php?id=$1 [L] </code></pre> <p>EX: Let say $category_name = Cars and $id =15 then the url should look: Cars-15.htm</p> <p>I thank you in advance</p>
php
[2]
4,311,243
4,311,244
Use a web service or to calculate locally?
<p>I`m new to Android, and i want to build an app which finds the cheapest product price form all stores. So the user selects a product(s) (all the stores has the products(s)), and the app returns a list of all the stores and the prices for that product(s). Lets say i have a database with total of 3000 rows, is it better to download the whole database when the app starts (it will have a updated database every week) and handle the calculations locally or just to communicate with a web service every time a product and a calculation is needed? Meaning is it better to have better response time by downloading the whole database first, or just to wait the web service each time a calculation is needed ?? What do u think is better from a user perspective? For me is easyer to chose a web service because i have them coded already (.asmx services), but which approach is better to choose? </p>
android
[4]
1,873,976
1,873,977
How to loop through files in a directory and output the contents of each file in a <div>
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/6155533/loop-code-for-each-file-in-a-directory">Loop code for each file in a directory</a> </p> </blockquote> <p>I assumed that I can reach this with following code but i think i make someting wrong with this code <code>include($file[$])</code></p> <pre><code>&lt;?php $dir= opendir(".") or die ('Cannot open directory'); $div="&lt;div class=\"left1\"&gt;\n"; echo "&lt;div class=\"wrapper\"&gt;\n"; for( $i=0; $i&lt;6; $i++){ while(($file = readdir($dir)) != false){ if(preg_match("/php$/", $file)){ echo $div; include($file[$i]); // HERE ITS NOT WORKING AS I WANT echo "&lt;/div&gt;\n"; } } } echo "&lt;/div&gt;\n"; ?&gt; </code></pre>
php
[2]
5,309,083
5,309,084
Return multi kinf of Object of Web Service in Java
<p>I am using web service in Java.Here is my problem:</p> <pre><code>public Object execute(int servicecode) { switch (servicecode) { case 1: return OBJECT_1; case 2: return OBJECT_2; case 3: return OBJECT_3; } } </code></pre> <ul> <li>My function returns OBJECT_1,OBJECT_2,OBJECT_3. I want client to understand: <ul> <li>case 1 Object=OBJECT_1</li> <li>case 2 Object=OBJECT_2</li> <li>case 3 Object=OBJECT_3</li> </ul></li> </ul> <p>How can I do it in a Web Service? I tried to use inheritance in the Web Service but I can't get properties of OBJECT_1, OBJECT_2, OBJECT_3.</p>
java
[1]
1,531,518
1,531,519
Killing a program using multiprocessing
<p>I'm using the multiprocessing module to do parallel processing in my program. When I'm testing it, I'll often want to kill the program early when I notice a bug, since it takes a while to run to completion. In my Linux environment, I run my program from a terminal, and use Ctrl+C to kill it. With multiprocessing, this causes all the processes to be killed, but I never get the bash prompt back, and have to close the terminal and open a new one (and navigate back to my working directory) which is quite annoying. Is there any way to get around this?</p>
python
[7]
3,569,804
3,569,805
probability c++ question
<p>I have to make a game of craps and towards the end, I have to do some probability. Here is my code so far. I want it so that the loop repeats 1000 times and looks for the 'probNumb' that the user entered. I am not sure if did this right but lets say I entered the number 5. This is what I get.<br> "Out of 1000 times, 5 was rolled 1000 times." </p> <p>So, its not counting how many times 5 was rolled. I am not allowed to use break or continue statements, only loops and if else. </p> <pre><code> cout &lt&lt "What number do you want the probability of ?"; cin >> probNumb; while (probCount &lt 1000) { ranNumb= 1 + (rand() % (5 + 1)); ranNumb2= 1 + (rand() % (5 + 1)); ranNumbFin = ranNumb + ranNumb2; probCount++; if (ranNumbFin = probNumb) probNumbCount++; } cout &lt&lt "Out of 1000 times, " &lt&lt probNumb &lt&lt " was rolled " &lt&lt probNumbCount &lt&lt "times." &lt&lt endl; </code></pre>
c++
[6]
3,471,546
3,471,547
How can we add buttons at dynamic positions in layout
<p>How can we add add buttons at dynamic positions in layout or using canvas ,not in table layout Can anyone please help me on this.</p>
android
[4]
3,975,913
3,975,914
SIMPLE HTML DOM Fatal Error Call to a member function find() on a non-object
<p>Im using Simple HTML DOM Library and im getting error </p> <p>Fatal error: Call to a member function find() on a non-object in /home/rodingo/public_html/crawler/music.php on line 14</p> <p>However it is working fine on localhost but causing problem on my Dedicated Server. cURL, fopen everything is enabled but still.</p> <pre><code> include('includes/simple_html_dom.php'); $html = file_get_html('http://mp3skull.com/mp3/'.$mp3name.'.html'); $list = array(); echo $html; foreach ( $html-&gt;find('div#song_html ') as $e ) { // &lt;-- LINE 14 $song = array(); $song['bit'] = preg_replace('!\s+!', ' ',$e-&gt;find('div', 0)-&gt;plaintext); $song['title'] = preg_replace('!\s+!', ' ',$e-&gt;find('div', 1)-&gt;plaintext); $song['url'] = preg_replace('!\s+!', ' ',$e-&gt;find('a', 0)-&gt;href); $list[] = $song; } </code></pre>
php
[2]
1,907,500
1,907,501
how to delete data from list view
<p>I want delete data from my <strong>listview</strong> using <strong>json</strong> ,where data comes from <strong>webserver</strong>.I tried <strong>AlertDialog</strong> to solve this problem ,but not successful. plz help me... thanks</p>
android
[4]
492,577
492,578
Is it possible to decrypt encoded php by ioncube?
<p>I have a php web application that I bought, and most of the files are encrypted with IONCUBE. Is possible to decrypt/decode these files so that I will be able to modify code to better meet my needs?</p>
php
[2]
2,099,340
2,099,341
Simple question from a very no experienced programmer
<p>Simple question: This is a method I created</p> <pre><code>public void move() { double radians = direction * Math.PI / 180; //change the x location by the x vector of the speed X_Coordinate += (int)(speed * Math.Cos(radians)); //change the y location by the y vectior of the speed Y_Coordinate -= (int)(speed * Math.Sin(radians)); } </code></pre> <p>How do I take a value enter into a text box, use a button called move, to call this method and display the result?</p>
c#
[0]
1,021,070
1,021,071
Div Appear After 5 Seconds Jquery
<p>I'm having problems getting a div to appear using jquery after 5 seconds.</p> <p>right now I was using</p> $(document).ready(function() { $("#message").delay(delay).fadeIn(5000); }); <p>But it's not working (#message being the name of the div serounding the content I'd like to show)</p> <p>If anyone could help me get it working that would be great.</p> <p>Thanks </p>
jquery
[5]
320,818
320,819
Kill session in C# (asp), if I have ID of session
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/5330268/how-to-kill-a-session-or-session-id-asp-net-c">How to Kill A Session or Session ID (ASP.NET/C#)</a> </p> </blockquote> <p>If I have the ID of all sessions in a aray, is it possible to verify that the session has timed out and kill it on that basis?</p>
asp.net
[9]
5,910,700
5,910,701
How to get the control path property of a user control?
<p>I have a user control which is hosted in a content placeholder. </p> <p>This is just 1 scenario, but the user control gets used all over the site. </p> <p>The user control is responsible for generating a JSON request, and to my horror I'm noticing that the form element id's / names aren't what I've called them - instead prefixed by controlID_ContentPlaceHolderID_UserControl_MyActualFormElementName</p> <p>I know I can turn this off if I was using .net v4, but the project is v2. </p> <p>Please can you tell me how to grab the control path in the code behind, and by this I mean dynamically determine the ctl00_ContentPlaceHolder_UserControlID part. </p> <p>I could then create another form element -> post through the name -> and then server side after the post, know what my form elements are. </p> <p>Thanks in advance. </p>
asp.net
[9]
288,025
288,026
Is there any speed/efficiency benefit to setting a class' instance variables in a constructor rather than in their declaration if they'll have a "default" value?
<p>For instance:</p> <pre><code>public class Foo { private int bar = 42; Foo() {} } </code></pre> <p>vs</p> <pre><code>public class Foo { private int bar; Foo() { bar = 42; } } </code></pre> <p>Is there any cost/benefit between the two methods? The only way I could see it making a difference is in a scenario like this (where you're setting a value twice for the second constructor):</p> <pre><code>public class Foo { private int bar = 42; Foo() {} Foo(int in) { bar = in; } } </code></pre> <p>vs (where either way you're only setting it once)</p> <pre><code>public class Foo { private int bar; Foo() { this(42); } Foo(int in) { bar = in; } } </code></pre> <p>Am I missing something? Is there any inherent value in doing it one way or the other?</p> <p><strong>&lt;EDIT&gt;</strong> Ok, I realize these are functionaly equivalent, What's I'm trying to figure out is if there are any significant processing costs associated with one over the other. Seems like it should be negligable, at best, but I'd like confirmation of my suspicions. <strong>&lt;/EDIT&gt;</strong></p> <p><strong>&lt;EDIT2&gt;</strong> I also realize that manually setting them eliminates the possibility of initilization logic. That's why I chose such simple examples. I edited the question text to reflect that what I'm interested in is efficiency. <strong>&lt;/EDIT2&gt;</strong></p>
java
[1]
1,533,233
1,533,234
Is there a better way to combine two string sets in java?
<p>I need to combine two string sets while filtering out redundant information, this is the solution I came up with, is there a better way that anyone can suggest? Perhaps something built in that I overlooked? Didn't have any luck with google.</p> <pre><code>Set&lt;String&gt; oldStringSet = getOldStringSet(); Set&lt;String&gt; newStringSet = getNewStringSet(); for(String currentString : oldStringSet) { if (!newStringSet.contains(currentString)) { newStringSet.add(currentString); } } </code></pre>
java
[1]
1,394,962
1,394,963
JavaScript slider Image and text from php, scrollable in groups by indexes
<p>I am looking for a JavaScript solution that slides images with text, pulled from php. This slider will slide in groups by indexes in points.</p> <p>I was Googling, but nothing as I need. I am going to make an example. Imagine 10 products. I need to show the principal picture, and a text below the image. It is going to show 6 products, and with points (indexes), I click and the group slides to the next group.</p> <p>Do you know some script? I know the php code, but I am a newbie with JavaScript.</p>
javascript
[3]
615,889
615,890
Easy way to add a background image to the default android notification layout
<p>I'm trying to figure out how to add a background image to the default android notification layout without having to use a custom notification layout. Is this possible or do i really have to re-create the default notification layout?</p>
android
[4]
2,913,500
2,913,501
send email after validation
<p>hi i am new enough to JavaScript and am wonder how to send details in email after validation ,heres my code </p> <pre><code>&lt;script type="text/javascript"&gt; var compName=false; var compContry=false; var compsub=false; var compphone=false; var compemail=false; function validate_form(form) { if(compName) { document.getElementById('country').focus(); compName=true; if(compContry) { document.getElementById('subject').focus(); compContry=true; if(compsub) { document.getElementById('Phone').focus(); compsub=true; if(compphone) { document.getElementById('email').focus(); compphone=true; if(compemail) { //I just use alert to show it works. alert("Your Details Are Sent "); compemail=true; } else { document.getElementById('email').focus(); compemail=false; } } else { document.getElementById('Phone').focus(); compphone=false; } } else { document.getElementById('subject').focus(); compsub=false; } } else { document.getElementById('country').focus(); compContry=false; } } else { document.getElementById('username').focus(); compName=false; } } </code></pre>
javascript
[3]
1,589,043
1,589,044
how to listen for changes in Contact Database
<p>I am trying to listen for any change in the contact database.</p> <p>So I create my contentObserver which is a child class of ContentObserver:</p> <pre><code> private class MyContentObserver extends ContentObserver { public MyContentObserver() { super(null); } @Override public void onChange(boolean selfChange) { super.onChange(selfChange); System.out.println (" Calling onChange" ); } } MyContentObserver contentObserver = new MyContentObserver(); context.getContentResolver().registerContentObserver (People.CONTENT_URI, true, contentObserver); </code></pre> <p>But When I use 'EditContactActivity' to change the contact database, My onChange function does not get called.</p>
android
[4]
2,747,586
2,747,587
How to make progress bar works while web browser navigating?
<p>I'm working with progress bar and web browser control on C# but I have no idea to make a smooth progress bar while it navigating, do you have step by step to create it, I will appreciate it.</p>
c#
[0]
2,289,789
2,289,790
Class reference in Java
<p>Hello Guys :D Why can't I execute the following code withoud getting a runtime exception? How should it be rewritten? I am migrating from C++ where I could easily do that I suppose :D.</p> <pre><code>class MyJavaClass { public static void main(String args[]) { Dog bushui_RIP = new Dog(); Dog fellow = null; bushui_RIP.bark(fellow); fellow.bark(); } } class Dog { public void bark(Dog buddy) { buddy = this; } public void bark() { System.out.println("I am barking!!!"); } } </code></pre>
java
[1]
3,449,426
3,449,427
Finding all the objects that are pointing to a certain object? (python)
<p>If I have the ID of some object for example, how can I find out all the objects that are pointing to it?</p>
python
[7]
5,394,061
5,394,062
Can I call a com object from a referenced .net library in asp.net 3.5
<p>I'm using ASP.NET on C# and I have a referanced library in the same solution in VB which calls a COM object using CreateObject.</p> <p>When I run the site on my comp it works, when I run it on my IIS 6 it gives me a stackoverflow on the method call.</p> <p>Now I have a script wich runs the VB code on the IIS6 and it works just fine. It must be something with the ASP...</p> <p>How can I call Com objects within ASP..., Do I have to do something special?</p> <p>Pls help.</p>
asp.net
[9]
5,375,634
5,375,635
android activities
<p>i have 2 activities. 1-Messaging 2-fileBrowser from MESSAGING onButtonClick i call the FILEBROWSER activity. in the FILEBROWSER activity i take the path of the selected file and put it to a interface and then call the MESSAGING activity again like this : </p> <pre><code> Intent i = new Intent(FileBrowser.this, Messaging.class); i.putExtra(FriendInfo.P, path); System.out.println("path at fb" + path); startActivity(i); this.finish(); </code></pre> <p>now when i m returned back to the MESSAGING activity everything over here is null. all the variables and everything and if i call some other methods, the arguments i pass are also null. what do i do ?</p>
android
[4]
767,857
767,858
View a huge file from the webbrowser
<p>I have a 150MB txt file of server logs. Probably with PHP, I want to view 100 lines at a time starting from the end of the file. When the user clicks "Pevious 100 lines" or something, the next set of 100 is loaded.</p> <p>What would be the best way to approach this?</p> <p>I've seen these ajax chat widgets that have a similar feature, how do they do this task?</p>
php
[2]
1,968,591
1,968,592
Javascript login code additional feature?
<p>Hi guys this might be a simple one, but then again i'm a little simple occassionaly.</p> <p>I have a login box using a simple javascript login comparing usernames and passwords, before you all start I know about the security issues in using javascript for authentication. Here is the code</p> <pre><code>function validate() { var un = document.getElementById("usern").value; var pw = document.getElementById("pword").value; var valid = false; var unArray = ["markwalt", "jongossy", "lisacain", "jenndemp"]; var pwArray = ["mark1234", "flomaygo", "lisa1234", "jenny1234"]; var fnArray = ["Mark Walters, Jonathan Goss, Lisa Cain, Jenny Dempsey"]; for (var i=0; i &lt;unArray.length; i++) { if ((un == unArray[i]) &amp;&amp; (pw == pwArray[i])) { valid = true; break; } } if (valid) { alert ("Login was successful"); document.getElementById("mandatory1").value = un; } else { alert("Invalid Username and/or Password! Please try again. You will not be able to submit this form without a successful login") document.getElementById("pword").value = ""; document.getElementById("usern").value = ""; document.getElementById("usern").focus(); } } </code></pre> <p>The issue i have is that at the moment if the login is succesful im posting the username to a hidden field which is then being used by a piece of a software. My question is how do i associate the names in fnArray with the other correct username &amp; password so that i can then grab associated full name and post that to the hidden field "mandator1" instead?</p> <p>Thanks in advance</p>
javascript
[3]
775,214
775,215
Pressing enter on any textbox invokes my Save button click event?
<p>I have a standard asp.net webform with multiple textboxes (Autopostback=False) on it and a Save button.<br /> Pressing ENTER while in any textbox is causing the server side click event of the Save button to be invoked. If I break and look at the call stack, the click event is the only event listed. I do not have a default button set for the form. If I put another button above the save button, then it gets its click event invoked on any press of enter on a textbox.</p> <p>Any ideas why this is happening, and how to get it to stop?</p>
asp.net
[9]
877,599
877,600
Open itunes from IPhone app
<p>I need to open Itunes app store from my application. I used the following Link. But the error is <strong><em>"Your Request Could Not Be Completed"</em></strong>.</p> <p>My code like as Below...</p> <pre><code>NSString *referralLink = @"http://itunes.apple.com/us/album/esperanza/id321585893"; NSURL *iTunesURL = [NSURL URLWithString:referralLink]; NSURLRequest *referralRequest = [NSURLRequest requestWithURL:iTunesURL]; NSURLConnection *referralConnection = [[NSURLConnection alloc] initWithRequest:referralRequest delegate:self startImmediately:YES]; [referralConnection release]; [[UIApplication sharedApplication] openURL:iTunesURL]; </code></pre> <p>Please any one knows the solution, please help me.</p> <p>Thanks..</p>
iphone
[8]
4,957,377
4,957,378
how to control/delay subsequent click events on same element
<pre><code>$navNext.click(function(event, $diff) { if(!$diff) { var $lastLi = $nav.find('li:last'); var $lastLiRight = $lastLi.offset().left + $lastLi.outerWidth(); if ($arrowsNavRight &lt; $lastLiRight) $diff = Math.min($lastLiRight - $arrowsNavRight, 50); } if($diff) { $navPrev.show('fade'); $nav.animate({ left: '-='+$diff }, function(){ showNavs(); }); } }); </code></pre> <p>This is click-handler of one <code>li</code> element. This calculation is to navigate a <code>ul</code> list of scrollable tabs. User can click several time on this <code>li</code> to reach desired position. but when there is no scope to scroll further I disable this <code>li</code>.</p> <p>Problem is: if user click on this <code>li</code> elements too fast then all this click events will be performed before hiding <code>li</code> (calling showNavs function). which can lead to extra scroll of <code>ul</code>.</p> <p>I want to control subsequent click event on this <code>li</code>. means, if one click is in progress then delay the next click. is there any way to do it?</p> <p>Thanks</p>
jquery
[5]
135,626
135,627
Multiple Javascript conflict
<p>I'm trying to get 2 scripts to run on the same page but they won't play nice with each other. One is called TabTop <a href="http://www.isdntek.com/tagbot/tabtop.htm" rel="nofollow">http://www.isdntek.com/tagbot/tabtop.htm</a> and the other is Clic*Pic <a href="http://www.isdntek.com/tagbot/gallery.htm" rel="nofollow">http://www.isdntek.com/tagbot/gallery.htm</a>, both by isdntek. I can get either one of them to run fine all by themselves, but not both together. I looked around and tried to find the answer to this problem by myself, but to no avail.</p> <p>I would greatly appreciate any help that can be provided.</p> <p>Thanks!</p>
javascript
[3]
536,218
536,219
how to store wikipedia document in local database or in application itself by programming?
<p>I am implementing on wikipedia iphone application.In which I have implemented below features.</p> <ul> <li>User can search the wikipedia using keyword.</li> <li>User can view wikipedia in webview.</li> </ul> <p>Query. Now I want to store this wikipedia in application or sqlitedabas.</p> <p>So when net is not available at that time user can view wikipedia from the application or local database.</p> <p>PLease help me for this query..</p> <p>Thanks in advance</p>
iphone
[8]
4,325,075
4,325,076
How can I include '\n' into the while (cin >> x) idiom?
<p>My understanding is that the operator <code>&gt;&gt;</code> returns the left operand, so <code>cin &gt;&gt; x</code> returns <code>cin</code> which has a value of <code>false</code> if we encounter an <code>EOF</code> or other errors. Now my guess is that since <code>cin</code> skips whitespace, characters like <code>\n</code> don't get stored. What I'd like to do is something like this:</p> <pre><code>int x; while((cin &gt;&gt; x) and x != '\n') // do stuff </code></pre> <p>So that when <code>cin</code> encounters a newline in the stream, it exits the input loop (as it would normally do with say, <code>EOF</code>).</p>
c++
[6]
1,585,647
1,585,648
Python 3.3, Issues with PATH
<p>All, I am just beginning with learning Python 3.3. After installing Python 3.3 and having the installer update my <code>PATH</code> (on Windows Vista) automatically, I am trying just typing <code>python</code> from any directory on my <code>C:\</code> drive and am receiving an error:</p> <blockquote> <p>python is not recognized as an internal or external command.</p> </blockquote> <p>ONLY when I navigate to <code>c:\Python33</code> and run <code>python</code> does it recognize the program and show the version number. </p> <p>I manually went to my Environment variables in Control Panel -> System -> Advanced settings -> Environment Variables -> PATH, to make sure c:\Python33 is listed in the PATH. </p> <p>Am I missing something else? </p>
python
[7]
5,084,855
5,084,856
How can I read a text file using Javascript?
<p>How can I read a <code>.txt</code> file in Javascript? I have a folder name and need to load the file present in the folder (there is only one). For example, if I have a folder called <code>folder1</code> it contains 3 same txt files with different name and other files also present in that folder1 I need to read only one txt file any one.</p>
javascript
[3]
1,991,028
1,991,029
using writeMethod to write on a property of an object?
<p>Hi guys I have a problem that makes me really confused, I have 'writeMethod' which is a type of Method class, 'dpv' which is a type of a propertyDescriptor, i retrieved the writeMethod of the object by getWriteMethod(), now my problem is how to set 'writeMethod' to write on a property of an object (e.g. JLabel, JButton) here is my code :</p> <pre><code> if(dpv.getPropertyType().isPrimitive() || dpv.getPropertyType().isInstance("Integer") ) { Method writeMethod = dpv.getWriteMethod(); //setWriteMethod(writeMethod);&lt;---------- Not sure about this part (doesn't work) System.out.println(writeMethod); PropertyValue.setEnabled(true); SetButton.setEnabled(true); } else{ PropertyValue.setEnabled(false); SetButton.setEnabled(false); } </code></pre> <p>Thanks for your help guys</p>
java
[1]
4,209,685
4,209,686
speech to text in android
<p>like the tts engine , is there a way by which speech can be converted to text in android?</p>
android
[4]
1,527,975
1,527,976
Changing fragment from SearchView submit aka Cascading down the backstack
<p>I'm currently using a <code>SearchView</code> object in order to give my application functionality for suggested input.</p> <p>This widget however, when submitted, uses an <code>intent-filter</code> to to initiate your searching. This is great when my application is run on a phone because what I want to do is launch a Search Results <code>Activity</code> to display the response. <strong>However</strong> on a tablet I want it to load my search results in a Fragment located in the current <code>Activity</code>!</p> <p>I want my app to be as unified as possible (In terms of crossover between phone/tab) so instead of overwriting the submit behaviour as suggested <a href="http://stackoverflow.com/questions/6938952/android-create-custom-searchview-search-action">in this answer</a> I would like a new activity to be started which routes the search term where it needs to go. On a phone to the results Activity, on a tab I would like to pass the searchTerm to the previous Activity.</p> <p>So I would like to ask - Can you pass information to a previous Activity in the backstack?</p>
android
[4]
1,390,663
1,390,664
Incorrigible error keeps popping ug, can't solve, help please?
<p>I'm a newbie to Java and I keep getting this stupid error that I can't solve. Here's my code:</p> <pre><code>class HelloWorldApp { public static void main(String [] args) { System.out.print1n("Hello World!"); } } </code></pre> <p>This is the error I keep getting while I try compiling:</p> <pre><code>error: Cannot find symbol symbol: method print1n (String) location: variable out of type PrintStream </code></pre> <p>Naargh...</p>
java
[1]
3,106,681
3,106,682
Changing views for a help screen
<p>I would like to add a "Help" screen to my app using the options menu, and have it include a button to "Returen" back to the original view.</p> <p>I have the written the "onOptionsItemSelected" routine(or is it a method?) using "swithch &amp; case" to check for which menu button was pressed. When the "help" button is pressed, I would like a new view to pop up showing the text I have typed in myhelp.xml file located in the R.layout folder. The myHelp.xml file includes a button named "quithelp" to return the user back to the main program (or is it the class?) </p> <p>I don't understand two things: how to switch to the myhelp.xml view when the menu button is pressed, and how to return back to the main menu when the "Return" button is pressed.</p> <p>I've experimented with LayoutInflator, getLayoutInflator,setFeatureInt based on some poor examples I found on the net, and now I'm just simply confused as to how best do such a simple task.</p>
android
[4]
2,308,023
2,308,024
How can I wait for a file to be uploaded (via ftp), then delete it?
<p>Using Python, how can I wait for a file to be uploaded (using ftp) before deleting it? </p> <pre><code>uploadFile(ftp, filepath,namef) # ............Here, I need to wait........ os.remove(filepath) </code></pre> <p>Any ideas?</p>
python
[7]
3,887,935
3,887,936
Selecting right tools for iphone app dev
<p>I have been surfing the web to find the best to develop small iphone app on WINDOWS XP SP3.</p> <p>Question :- Is it possible to develop a simple iphone application, that connects to MSSQL database gets the data and displays in iphone app.</p> <p>Can anybody please suggest the right tools to select..</p> <p>Thanks a lot for suggestions..</p>
iphone
[8]
4,573,430
4,573,431
Initializing member variables using the same name for constructor arguments as for the member variables allowed by the C++ standard?
<p>I figured out that it's possible to initialize the member variables with a constructor argument of the same name as show in the example below.</p> <pre><code>#include &lt;cstdio&gt; #include &lt;vector&gt; class Blah { std::vector&lt;int&gt; vec; public: Blah(std::vector&lt;int&gt; vec): vec(vec) {} void printVec() { for(unsigned int i=0; i&lt;vec.size(); i++) printf("%i ", vec.at(i)); printf("\n"); } }; int main() { std::vector&lt;int&gt; myVector(3); myVector.at(0) = 1; myVector.at(1) = 2; myVector.at(2) = 3; Blah blah(myVector); blah.printVec(); return 0; } </code></pre> <p>g++ 4.4 with the arguments <code>-Wall -Wextra -pedantic</code> gives no warning and works correctly. It also works with clang++. I wonder what the C++ standard says about it? Is it legal and guaranteed to always work?</p>
c++
[6]
2,862,577
2,862,578
Is it better to eval dynamically-generated code or store it in a temp file and include it?
<p>Sometimes I need to create PHP code for formatting arrays on the fly. one way to do this is to use <code>eval</code>. but I think of writing the generated code to a PHP file and then include it. This has many advantages to <code>eval</code>, one of them is caching of generated code. But I haven't seen such a practice in other code. I don't know if there's any problem regarding security or other things with this?</p> <p>This is an example:</p> <pre><code>&lt;?php $code = '&lt;? foreach($rows as $row) {$row["insertion"] = format($row["insertion"]);} ?&gt;' file_put_contents('formatter.php', $code); include('formatter.php'); ?&gt; </code></pre> <p>I just want to know is it good to create a PHP file on the fly and then include it?</p> <p>Or is it better to just go ahead and <code>eval()</code> the code directly, with no stored history?</p>
php
[2]
233,727
233,728
Good approach to develop android Tablet app
<p>I have got a project that implement tablet version of an app. this app has only portrait mode without landscape mode support. so my approach would be implementation for both in tablet. </p> <p>however, you guys all know that android has different type of devices and android version. how to make sure that my tablet app will work for every tablet devices. also UI, what is the best practice to do in tablet?how can i make sure my app layout is fit in all devices? what kind of UI framework would be useful for developing android tablet? </p> <p>thanks a lot !!! I would appreciate the sharing of your experiences.</p> <p>regards justicepenny</p>
android
[4]
4,831,870
4,831,871
Why image not show?
<p>Good day.</p> <p>I have a problem with show image...</p> <pre><code>$.modal('&lt;div id="modal_window_result"&gt;Test&lt;br&gt;&lt;br&gt;&lt;br&gt; &lt;img src="./images/image.gif" width="100" height="100" /&gt;&lt;/div&gt;'); $('#modal_window_result').html('').html('TextTextTextText&lt;br&gt;&lt;br&gt;&lt;br&gt; &lt;img src="images/yes.png" width="100" height="100" /&gt;'); </code></pre> <p><code>image.gif</code> created, then show text <code>TextTextTextText</code>, but image <code>yes.png</code> not show...</p> <p>i see code and see:</p> <pre><code>&lt;div id="modal_window_result"&gt;TextTextTextText&lt;br&gt;&lt;br&gt;&lt;br&gt; &lt;img src="images/yes.png" width="100" height="100"&gt;&lt;/div&gt; </code></pre> <p>Tell me please where error? </p> <p>Why image <code>yes.png</code> not show?</p>
jquery
[5]
5,767,124
5,767,125
Extremely slow random string generator
<p>I came up with the below code to generate 100001 random strings.the strings should be unique. However, the below code takes hours to do the job. Can someone let me know how i can optimize it and why is it so slow?</p> <pre><code>string getRandomString(int length) { static string charset = "abcdefghijklmnopqrstuvwxyz"; string result; result.resize(length); for (int i = 0; i &lt; length; i++) { result[i] = charset[rand() % charset.length()]; } return result; } void main(){ srand(time(NULL)); vector&lt;string&gt; storeUnigrams; int numUnigram = 100001; string temp = ""; int minLen = 3; int maxLen = 26; int range = maxLen - minLen + 1; int i =0; while(i &lt; numUnigram){ int lenOfRanString = rand()%range + minLen; temp = getRandomString(lenOfRanString); bool doesithave = false; for(int j =0 ; j &lt; storeUnigrams.size() ; j++){ if(temp.compare(storeUnigrams[j]) == 0){ doesithave = true; break; } if(temp.compare(storeUnigrams[j]) &lt; 0){ break; } } if(!doesithave){ storeUnigrams.push_back(temp); sort(storeUnigrams.begin(),storeUnigrams.end()); i++; } } </code></pre>
c++
[6]
3,066,721
3,066,722
jquery why isn't this working?
<pre><code>$(document).ready(function() { $('#comment textarea').click(function() { if (this.value == this.'Post a comment') { this.value = ''; } }); $('#comment textarea').blur(function() { if (this.value == '') { this.value = this.'Post a comment'; } }); }); </code></pre> <p>I have this bit of script stuck on a php file. However it is not functioning. The textarea's default value is Post a comment. This script should change the textarea's value to null on click, and then on blur change it back to post a comment.</p>
jquery
[5]
244,224
244,225
jQuery: how do I append variables onto a form path?
<p>Lets say the URL in my form is </p> <pre><code>action="/medias/new_from_disk?CKEditor=content_body&amp;CKEditorFuncNum=1&amp;langCode=en" </code></pre> <p>and the form has ID <code>myform</code> how would I conjure a jQuery command to add to the action</p> <pre><code>&amp;var=value </code></pre> <p>?</p> <p>complete form: </p> <pre><code>&lt;form enctype="multipart/form-data" id="myform" method="POST" action="/medias/new_from_disk?CKEditor=content_body&amp;amp;CKEditorFuncNum=1&amp;amp;langCode=en"&gt; &lt;/form&gt; </code></pre>
jquery
[5]
1,916,480
1,916,481
Toggle attr value on click
<p>I'm trying to toggle a attr value (rel or href) on click.</p> <pre><code>$('#open').click(function () { $(this).text($(this).text() == 'View Project' ? 'Close' : 'View Project'); $(this).attr('rel','#page'); $('#view').slideToggle(550); return false; }); </code></pre> <p>I've got a text swap in there that's change out the text for a#open when toggled open/toggle close.</p> <p>But I need to swap the <strong>rel</strong> or <strong>href</strong> from <strong>#view</strong> to <strong>#page</strong> when toggled open but then back to <strong>#view</strong> on the toggle close. I'm needing the swap of these as it's needed for using scrollTop.</p> <p>Any help would be greatly appreciated!</p>
jquery
[5]
5,691,391
5,691,392
Javascript not working on firefox
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/1359469/innertext-works-in-ie-but-not-in-firefox">&#39;innerText&#39; works in IE, but not in Firefox</a> </p> </blockquote> <p>Why the following script work on IE and safari but not in Firefox?</p> <pre><code>&lt;html&gt; &lt;head&gt;&lt;script type="text/javascript"&gt; function ShowHide(strTag ,strAttribute){ var elem = document.getElementsByTagName(strTag); var elem1 = evt.srcElement || evt.target; for (var i=0;i&lt;elem1.children.length;i++){ elem1.children[i].innerText=="4" ? elem1.children [i].innerText="6":elem1.children[i].innerText="4"; } for (var i =0;i&lt;elem.length;i++) { if(elem[i].getAttribute(strAttribute)=="yes") { elem[i].style.display=='none'? elem[i].style.display='block':elem [i].style.display='none'; } } } &lt;/script&gt; &lt;div id=div1 onclick="ShowHide('div','exp2');"&gt; &lt;font face=Webdings color=BLACK&gt;4&lt;/font&gt; click here for some expandable divs...&lt;/div&gt; &lt;div id=div2 exp2='yes' style="display:none;"&gt;I'm a div!&lt;/div&gt; &lt;div id=div3 exp2='yes' style="display:none;"&gt;More of them divs...&lt;/div&gt; &lt;div id=div4 exp2='yes' style="display:none;"&gt;Me too! divs...&lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
javascript
[3]
223,432
223,433
Making all the keys value in an array of objects blank
<p>How to make all the key's value in an object replace with blank values... </p> <pre><code>var array = [{key1:'value',key2:'value2'},{'key1:'value',key2:'value2}] for (item in arrayObj) { arrayObj[item] = ' '; } </code></pre> <p>Is the above code right... </p>
javascript
[3]
1,056,361
1,056,362
How to traverse dom elements in raw JavaScript?
<p>I do everything in jQuery but now am going back to learn JavaScript proper. So how could I do the equivalent of this in vanilla js:</p> <pre><code>$('ul li a', '#myDiv').hide(); </code></pre>
javascript
[3]
3,521,816
3,521,817
What is the difference between window and this.window, in javascript?
<p>I'm looking at a complex bit of JavaScript, which is doing all sorts of runtime/dynamic manipulation of objects and scripts. In the process, I'm learning all sorts of minutiae about Javascript and its idiosyncrasies.</p> <p>This one has me stumped, though. Is there ever a situation where</p> <pre><code>window !== this.window; //true </code></pre> <p>In other words, when would you ever write this.window instead of straight out window?</p>
javascript
[3]
967,465
967,466
Should I set my TextView colours if my background colour is not set?
<p>When I comes to specifying colours for an application, I recently came across <code>@android:color</code>. Is it recommended to try to always use predefined system colors?</p> <p>I changed the colours of some of my labels to something brighter, so that they'll stand out against the black background. But then I start to wonder... would themes/skins (not familiar with those) and such cause the default background colour to be something other than black?</p> <p>If so... what's the proper way to deal with colouring one's widgets?</p>
android
[4]
3,395,713
3,395,714
C#: In the keydown event of a textbox, how do you detect currently pressed modifiers + keys?
<p>C#: In the keydown event of a textbox, how do you detect currently pressed modifiers + keys?</p> <p>I did the following, but I'm not too familiar with these operators so I'm not sure if and what I'm doing wrong.</p> <pre><code> private void txtShortcut_KeyDown(object sender, KeyEventArgs e) { if (e.Modifiers == (Keys.Alt || Keys.Control || Keys.Shift)) { lbLogger.Items.Add(e.Modifiers.ToString() + " + " + "show non-modifier key being pressed here"); } } </code></pre> <p>1) How would I check if e contains any modifier keys?</p>
c#
[0]
5,104,561
5,104,562
Calling Distinct() on DataRow collection
<p>Trying to find unique rows in a data table using Distinct() extension method. Some rows contain exactly the same data, but for some reason, the hash code for these rows are different from each other.</p> <p>I wrote a comparer class implementing <code>IEqualityComparer&lt;DataRow&gt;</code>, however, I think what I'm doing in <code>GetHashCode()</code> is cheesy and nasty.</p> <p>The reason I've done it this way is because <code>Equals()</code> never gets called unless the hashcodes are the same (Expected behaviour)</p> <pre><code>class RowValidationComparer : IEqualityComparer&lt;DataRow&gt; { public bool Equals(DataRow x, DataRow y) { return x.Field&lt;string&gt;("MyField").Equals(y.Field&lt;string&gt;("MyField")); } public int GetHashCode(DataRow obj) { typeof(DataRow).GetHashCode(); } } </code></pre>
c#
[0]
3,142,681
3,142,682
is it possible to count an object as a "whole"?
<p>can i count an objects? like:</p> <pre><code> var student1 = new Student(); student1.name("ziv"); student1.age(); student1.where("a"); var student2 = new Student(); student2.name("dani"); student2.age(); student2.where("b"); var student3 = new Student(); student3.name("bari"); student3.age(); student3.where("c"); </code></pre> <p>some function that will count them and return 3 .</p> <p>thanks :)</p>
javascript
[3]
1,840,912
1,840,913
Can I prevent future developers from making an object constructable?
<p>you have a class A, where you set ctor to be private, so a client can't call "A a;" to create obj on stack. But someday another developer add a new ctor: "A(int)" and try to call "A a(1);" inside main(). So this will create a obj on stack. How do you prevent that?</p>
c++
[6]
2,892,286
2,892,287
Combine n lists of length y into y lists of length n
<p>If I have:</p> <pre><code>&gt;&gt;&gt; a=[1,2] &gt;&gt;&gt; b=[3,4] &gt;&gt;&gt; c=[5,6] </code></pre> <p>Is there a one-liner to get:</p> <pre><code>d = ([1,3,5],[2,4,6]) </code></pre>
python
[7]
552,646
552,647
How to get the value of a textbox inside a <td> using the id of <tr> in jquery
<p>i have a table like this</p> <pre><code>&lt;table&gt; &lt;tr id ='1tr'&gt; &lt;td&gt;&lt;input type='textbox' value='1'&gt;&lt;/td&gt; &lt;td&gt;&lt;input type='textbox' value='2'&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr id ='2tr'&gt; &lt;td&gt;&lt;input type='textbox' value='3'&gt;&lt;/td&gt; &lt;td&gt;&lt;input type='textbox' value='4'&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p>how i can get the value of text box in second td that is in tr with id 2tr</p>
jquery
[5]
2,164,918
2,164,919
How to get emails and save them into mysql database
<p>I got requirement to build a email box. In which I am going to save incomming and outgoing emails in/out of mysql database. How can I write a php script so my all emails will arrive in my mysql database?</p>
php
[2]
981,032
981,033
insert object into a set
<p>I want to insert a vector into a set like this:</p> <pre><code>set&lt;vector&lt;prmEdge&gt; &gt; cammini; vector&lt;prmEdge&gt; vecEdge; cammini.insert(vecEdge); </code></pre> <p>I have a compilation error like this:</p> <pre><code>prmPlanner.cpp:1285: instantiated from here /usr/include/c++/4.2/bits/stl_algobase.h:853: error: no match for ‘operator&lt;’ in ‘__first1.__gnu_cxx::__normal_iterator&lt;_Iterator, _Container&gt;::operator* [with _Iterator = const prmEdge*, _Container = std::vector&lt;prmEdge, std::allocator&lt;prmEdge&gt; &gt;]() &lt; __first2.__gnu_cxx::__normal_iterator&lt;_Iterator, _Container&gt;::operator* [with _Iterator = const prmEdge*, _Container = std::vector&lt;prmEdge, std::allocator&lt;prmEdge&gt; &gt;]()’ /usr/include/c++/4.2/bits/stl_algobase.h:855: error: no match for ‘operator&lt;’ in ‘__first2.__gnu_cxx::__normal_iterator&lt;_Iterator, _Container&gt;::operator* [with _Iterator = const prmEdge*, _Container = std::vector&lt;prmEdge, std::allocator&lt;prmEdge&gt; &gt;]() &lt; __first1.__gnu_cxx::__normal_iterator&lt;_Iterator, _Container&gt;::operator* [with _Iterator = const prmEdge*, _Container = std::vector&lt;prmEdge, std::allocator&lt;prmEdge&gt; &gt;]()’ make[1]: *** [prmPlanner.o] Errore 1 </code></pre> <p>What should I do? Could somebody help me??</p> <p>Thank you very much</p>
c++
[6]