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
1,316,012
1,316,013
How do you create a property for a custom object in JavaScript?
<p>I know I can create function for custom object like </p> <pre><code>var newObj = { myFunc1: function () { alert('hello'); }, myFunc2: function () { alert('hello'); } } </code></pre> <p>Now how can I create a new property so that i can set that property in myFunc1 or myFunc2 and and then latter on use it by doing newObj.myProperty.</p>
javascript
[3]
5,572,652
5,572,653
saving images from webcam stream directly to web server with java
<p>Is it possible to save images directly from the webcam of my system to a web server in Java? Maybe it can directly passed to an URL address and can be <code>GET</code> at the server or anything else.</p>
java
[1]
3,272,134
3,272,135
Dismissing popover, then popToRootViewController, EXC_BAD_ACCESS
<p>I am getting a crash when I <code>popToRootViewController</code>, this is the way I have it set up.</p> <p>I have: </p> <pre><code>@property (nonatomic, retain) UIPopoverController *popover; </code></pre> <p>in dealloc:</p> <pre><code>[popover release]; </code></pre> <p>when a button is pressed</p> <pre><code>if (self.popover == nil) { DetailViewController *detailView = [[[DetailViewController alloc] init] autorelease]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(GoToTest:) name:TestDetailPressed object:detailView]; self.popover = [[[UIPopoverController alloc] initWithContentViewController:detailView] autorelease]; self.popover.delegate = self; [self.popover presentPopoverFromRect:frame inView:self.scrollView permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; } </code></pre> <p>My <code>DetailViewController</code> is essentially just a <code>UITableView</code>. When a row is selected, I post a notification back to this current class for GoToTest:</p> <pre><code>- (void)GoToTest:(NSNotification *)notification { if ([self.popover isPopoverVisible]) { [self.popover dismisspopoverAnimated:YES]; [self handleDismissedPopover:self.popover]; } [self.navigationController popToRootViewControllerAnimated:NO]; } - (void)handleDismissedPopover:(UIPopoverController *)popoverController { self.popover = nil; self.popover.delegate = nil; [[NSNotificationCenter defaultCenter] removeObserver:self name:TestDetailPressed object:nil]; } - (void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController { [self handleDismissedPopover:popoverController; } </code></pre> <p>When I run it in Instruments, I get the zombie message for</p> <pre><code> -[UIPopoverController _popoverDismissAnimationCompleted] </code></pre> <p>and the <code>UIViewController</code> has a refCt of -1 at that point.</p>
iphone
[8]
2,307,291
2,307,292
C# Variable Name To String
<p>I have variable</p> <pre><code>public string MyVariable; </code></pre> <p>I need use name of variable as string. Example:</p> <pre><code>var a = MyVariable.NameVariable(); // a = "MyVariable" </code></pre> <p>How i may to do this?</p> <p>I would like to create your miniORM (NHibernate is too heavy and requires a separate library). At the moment the problem is that I have to point out a bunch of constants. For example:</p> <pre><code>public const string FieldIdRules = "idRules" </code></pre> <p>And then to make transactions in relation samonapisannom profiler. I saw that Hibernate does not need to specify the text value (for the ratio of fields). I want to implement the same.</p> <p>Sorry my bad english</p>
c#
[0]
253,892
253,893
JQuery textarea value is empty
<p>This type of question tends to immediately get a negative vote. If you have the answer, please help! Thanks.</p> <p>I have a script that adds a textarea to the dom. When I enter data and later try to retrieve it the value returns empty.</p> <p>This successfully sets the value of the textarea:</p> <pre><code>$("textarea").each(function(){ $(this).val("ASDFASDF"); }); </code></pre> <p>This successfully sets the css background property of the textarea:</p> <pre><code>$("textarea").each(function(){ $(this).css({"border":"2px solid red"}); }); </code></pre> <p>But this does not return the value:</p> <pre><code>$("textarea").each(function(){ alert($(this).val()); }); </code></pre> <p>I've tried .text(), .html(), .value - they all return nothing! It doesn't alert "undefined" or null but simply an empty value.</p> <p>I can't figure out why.</p> <p>Thanks in advance for the suggestions. </p> <p><strong>MORE INFO</strong></p> <p>HTML is:</p> <pre><code>&lt;textarea id="Bio" rows="4"&gt;&lt;/textarea&gt; </code></pre> <p>JQuery Library: <a href="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" rel="nofollow">http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js</a></p> <p>Function is triggered by a button after the dom is loaded.</p> <p>A simplified version of the code is here: <a href="http://social-gamer.com/textarea.html" rel="nofollow">http://social-gamer.com/textarea.html</a></p>
jquery
[5]
4,299,375
4,299,376
related to variables
<p>_Shopid =0;</p> <p>_forename=””;</p> <p>_dateofbirth=?</p> <p>id is int represented by 0 </p> <p>forename is string represented by double qoutations like ""</p> <p>how to represent dateof birth </p>
c#
[0]
994,891
994,892
Get thumbnail image of video from video url
<p>Is it possible to get the thumbnail image from a video Url? I need to thumbnails of videos in a list view.</p> <p>Thanks in advance benish</p>
android
[4]
834,765
834,766
User input asked twice
<p>The code below asks to input the numbers two times.</p> <pre><code>public class Palindrome { public static void main(String[] args) { boolean x; boolean display; x = check(); display = display(); } private static int getUserInput() { int inputNumber = 0; String answer = JOptionPane.showInputDialog(null, "Please enter a five digit number","Enter a number"); inputNumber = Integer.parseInt(answer); return inputNumber; } private static boolean check(){ int inputNumber = getUserInput(); int number = inputNumber; int[] myArray = new int[5]; for (int i = 0; i &lt; myArray.length; i++) { myArray[i] = (int) (number /(Math.pow(10,i)) % 10); } if(myArray[0] == myArray[4] &amp;&amp; myArray[1] == myArray[3]) return true; else return false; } public static boolean display(){ if (check() == true) { JOptionPane.showMessageDialog(null, "This number is a Palindrome", "Excellent!", JOptionPane.INFORMATION_MESSAGE); } else JOptionPane.showMessageDialog(null, "Number is not a Palindrome!", "Sorry", JOptionPane.ERROR_MESSAGE); return false; } } </code></pre> <p>I want it to ask just once.</p> <p>Thanks</p>
java
[1]
5,137,870
5,137,871
What is the right place to store persistent app data before exiting?
<p>I have a single <code>Activity</code> application with a data container that is populated at the launch of the application from a JSON formatted private text file. When exiting the application, whether it's a graceful exit or forced one, the the data must be written back to the text file.</p> <p>Android documentation <a href="http://developer.android.com/reference/android/app/Activity.html#onDestroy%28%29" rel="nofollow">states</a> that application data shouldn't be saved in the onDestroy method.</p> <p>I have now overwritten the following methods to make sure the data is stored at exit:</p> <pre><code>protected void onStop() { persistenceManager.storeIfChanged(); super.onStop(); } protected void onPause() { persistenceManager.storeIfChanged(); super.onPause(); } </code></pre> <p>The <code>storeIfChanged</code> methods writes the application data to the text file if it has changed since last save. <strong>My question is</strong>, does this guarantee the application data is saved no matter how the application is terminated (unless it's force majeure). <strong>Secondly</strong>, is it superfluous to do the saving in both onStop and onPause?</p>
android
[4]
3,076,141
3,076,142
How to get some elements from html source and convert them to readable text?
<p>I have a page which displays "HeLLo 54292" in ASCII art, using <code>+</code> characters inside <code>&lt;table&gt;</code> tags to produce block letters. I'm generating this with PHP. <a href="http://cmaempreendimentos.com/test/" rel="nofollow">You can check out page's html source code</a>, and see how the ASCII art is constructed. </p> <p>I want to convert the ASCII-art letters to actual text, so I could parse that HTML source and would end up with the string "HeLLo 54292". How would I accomplish this?</p>
php
[2]
1,705,736
1,705,737
ASP.NET chatting design and speed issues
<p>Ok. I am making a random chatting website here, and the website needs to know each user's new visit datetime and a randomID in order to retrieve the messages he/she made in a chatting room. When a user comes in to my website, he/she gets a unique random ID and start to talk to another person. Every comments they make gets saved in a database along with a randomly assigned chatroomID. Then, the database loads the messages in the chatroom (every 1 second) by identifying the users' new visit dates to the chatroomID and retrieving all the users' messages associated with the chatroomID in chronological order (from the new visit date). Do you think that this is a well-designed way to create a random chatting website and if not is there a better design alternative? :D If I reload the messages from the database every 1 second, won't there be speed or traffic issues? If I am not clear on my explanation, plz leave msg and ask me for the details.</p>
asp.net
[9]
5,581,237
5,581,238
Call by reference-stream and char in c++
<p>My latest homework assignment is to write a program that reads a textfile and outputs the number of lines, words and characters.</p> <p>I'm just starting out, all I'm trying to do right now is to let the user type in the file name and then the file will open. This is my not-working code, I must be missing something obvious, I'm just trying to pass the stream and char to the 'input' function. </p> <p>Any pointers?</p> <pre><code>#include &lt;iostream&gt; #include &lt;fstream&gt; #include &lt;cstdlib&gt; using namespace std; //Define functions. void input(ifstream&amp; fin, char&amp; fileName); int main() { ifstream fin; char fileName[20]; input(fin, fileName); return 0; } void input(ifstream&amp; fin, char&amp; fileName) { cout &lt;&lt; "Input file name: "; cin &gt;&gt; fileName; fin.open(fileName); if(fin.fail()) { cout &lt;&lt; "The file: " &lt;&lt; fileName &lt;&lt; " does not open." &lt;&lt; endl; exit(1); } //return; } </code></pre>
c++
[6]
3,262,989
3,262,990
how i can place my xml file in url in iPhone
<p>I am developing a XCAP application.In my application i am developing a xml file.Here my problem is this xml file,i want to place an url.can any one help to me? thank in advance</p>
iphone
[8]
435,117
435,118
file_put_contents() not over writing, just appending
<p>I have a simple <code>file.txt</code> which needs to be over written every time I run a certain php code.</p> <pre><code>$msg ="string"; $file = 'file.txt'; $opn = file_get_contents($file); $opn .= $msg; file_put_contents($file, $opn); </code></pre> <p>The code works perfectly, It added the string I want it to add, but It is appending it to the former. I want it to erase it blank and then write.</p> <p>I've read the manual <a href="http://php.net/manual/en/function.file-put-contents.php" rel="nofollow">http://php.net/manual/en/function.file-put-contents.php</a> I am not using the <code>FILE_APPEND</code> argument either.</p> <p>It's a simple thing that I'm not seeing. Help me out.</p> <p><strong>EDIT:</strong></p> <p>Here is the whole code. I'm getting some data from a site. The data is in this format <code>12.222 AAA</code> and I am trying to save that to a text file to easily access later. But for some reason something does not work. The scraper works perfectly, and the <code>file_put_contents()</code> woks perfectly if I set the <code>$item="string";</code> but it does not work when when <code>$item</code> is set to equal the code below. If I echo $item I get what I want.</p> <pre><code>&lt;?php include('simple_html_dom.php'); $html = file_get_html('http://site.com/boom'); // find the thing in the span foreach($html-&gt;find('div') as $article) { $item = $article-&gt;find('span', 0)-&gt;plaintext; echo $item; $file = 'file.txt'; $fh = fopen( 'file.txt', 'w' ); fclose($fh); $opn = file_get_contents($file); $opn .= $item; file_put_contents($file, $opn); } ?&gt; </code></pre>
php
[2]
2,590,672
2,590,673
jQuery subtracting successive table cells
<p>I'm trying to determine how to calculate the difference between successive table cells in jQuery. I have a table that looks like this. </p> <pre><code>&lt;table id ="tbl"&gt; &lt;tr&gt; &lt;td&gt;5&lt;/td&gt; &lt;td&gt;12&lt;/td&gt; &lt;td&gt;15&lt;/td&gt; &lt;td&gt;17&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;3&lt;/td&gt; &lt;td&gt;6&lt;/td&gt; &lt;td&gt;12&lt;/td&gt; &lt;td&gt;13&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p>I'd like to subtract the first td from the second td (12 - 5), the third from the second (15 - 12), the fourth from the third (17 - 15) etc. I need to do this for every row in the table. I'm sure the answer is simple, but I'm stuck. I know I'll need to loop through each row, but how can I efficiently make this calculation? </p> <pre><code>$('#tbl tr').each(function(){ // help! )} </code></pre>
jquery
[5]
4,847,731
4,847,732
How do I round a button programmatically in Android?
<p>I have a <code>Button</code> which populates a <code>GridView</code> using a custom adapter's call to <code>getView()</code>. As such, there is no .xml file for the <code>Button</code>.</p> <p>Is there a way to programmatically round the <code>Button</code>?</p>
android
[4]
4,521,889
4,521,890
how to read trace
<p>I have a snipnet which writes user name to trace.</p> <pre><code>Trace.WriteLine("Current User: " + userIdentity.Name); </code></pre> <p>How to read this information. I did good search in net, no luck. Can we read default trace?</p> <p>Thank in advance.</p>
c#
[0]
4,867,385
4,867,386
How can I separate a string so that the first words are in one variable and the last word is in another?
<p>I have a string that looks like this: <code>This is a sample string</code></p> <p>and I want to separate the sting so that the first words are in one variable and the last word is in another. So:</p> <pre><code>$beginning = "This is a sample" $lasword = "string" </code></pre> <p>How can I do that? </p>
php
[2]
3,166,668
3,166,669
How to call constructor of the current class and parent class at the same time?
<pre><code>public class A{ List m; public A(int a, int b) {m=new List(); ...} } public class B : A{ List a; List b; public B(){...} //constructor1 public B(int a, int b) : base(a,b){...} //constructor2 } </code></pre> <p>My question is I need to initialize both list a and b in class B. If I put them in the constructor1, how can I call constructor1 in constructor2? I don't want to rewrite the initialization statements in constructor2 again. Thanks!</p>
c#
[0]
3,613,736
3,613,737
newsgroup client
<p>I hope to develop a newsgroup client reader for iPhone. But I can not find out any technology concern this.</p> <p>Welcome any commnents</p> <p>Thanks</p> <p>interdev</p>
iphone
[8]
1,977,769
1,977,770
PHP Array count and get element values
<p>I'm pretty new to PHP and programming so I'm having troubles with this thing.</p> <p>The purpose of the whole situation is to read a column from tab delimited file (already did that), get all different items in it, count them individually and put them in table with <br><br>Column1[item value - label], Column2[count].</p> <p>I have the whole column in 1 dimension array. Now, I want to list all the items there and their counts beside. The problem is, I could have more than 10 different items, even more, so I can't do it manually (name 10 variables and count each) like this:</p> <pre><code>$arr = array("complete","fail","complete","exit","fail","fail","complete"); function isComplete($value){ return ($value == "complete") ? true : false; } $complete = array_filter($array, 'isComplete'); &lt;tr&gt; &lt;td&gt;Complete&lt;/td&gt; &lt;td&gt;&lt;?php echo count($complete)?&gt;&lt;/td&gt; &lt;/tr&gt; -- &gt; Complete = 3 </code></pre> <p>I want to avoid manually creating every function for each value because values can differ from file to file.</p> <p>The number of items in $array can go up to 20+k so I need all automated. Can someone help me with this?</p>
php
[2]
2,790,501
2,790,502
get Values from form elements in JQUERY?
<p>My form.html</p> <pre><code>&lt;form id="search-form" method="post" action="." name="f"&gt; &lt;p&gt;&lt;label for="id_customer_type"&gt;Customer type&lt;/label&gt; &lt;select name="customer_type" id="id_customer_type"&gt; &lt;option value=""&gt;All&lt;/option&gt; &lt;option value="TDO" selected="selected"&gt;TDO&lt;/option&gt; &lt;/select&gt;&lt;/p&gt; &lt;p&gt;&lt;label for="id_tag"&gt;Tag&lt;/label&gt; &lt;/p&gt;&lt;dl&gt; &lt;dt&gt;&lt;strong&gt;School&lt;/strong&gt;&lt;/dt&gt; &lt;dd&gt;&lt;label for="id_tag_1"&gt;&lt;input checked="checked" name="tag" value="2" id="id_tag_1" type="checkbox"&gt; Private&lt;/label&gt;&lt;/dd&gt; &lt;dd&gt;&lt;label for="id_tag_2"&gt;&lt;input checked="checked" name="tag" value="3" id="id_tag_2" type="checkbox"&gt; Public&lt;/label&gt;&lt;/dd&gt; &lt;/dl&gt; &lt;input id="filter" value="Filter" type="submit"&gt; &lt;/form&gt; </code></pre> <p>My script.js</p> <pre><code> $(document).ready(function(){ // Third way == UPDATE jQuery 1.3 $("input[type='checkbox']:checked").each(function(){ // your code checkboxs_ischecked = $("input[type='checkbox']").val(); }); $("#filter").click(function() { customet_type = $('#id_customer_type :selected').text(); checkbox_ischecked = ????? //How Can I get the checkboxs value that is checked? document.f.action = "/customer/show/?customer_type="+customet_type+"&amp; tag="+checkboxs_ischecked; // in my case something like this :checkbox_ischecked = Private_Public if I have checked Private and Public ; return true; }); }); </code></pre> <p>Thanks ! :)</p>
jquery
[5]
3,125,915
3,125,916
Get the list of a class's variables & methods in Python
<p>If I have the following class, what's the best way of getting the exact list of variables and methods, <em>excluding</em> those from the superclass?</p> <pre><code>class Foo(Bar): var1 = 3.14159265 var2 = Baz() @property def var3(self): return 42 def meth1(self, var): return var </code></pre> <p>I want the tuple <code>('var1','var2','var3','meth1')</code> with minimum overhead. This is being run in a Django environment, which seems to be putting some of it's class instance variables in the read-only <code>__dict__</code> variable; a feat which I can't find a way to replicate.</p> <p>Here's what I'm seeing while playing with it, any suggestions beyond trimming out the <code>__*</code> from the dir() or manually listing them?</p> <pre><code>&gt;&gt;&gt; a=Foo() &gt;&gt;&gt; a &lt;__main__.Foo instance at 0x7f48c1e835f0&gt; &gt;&gt;&gt; dict(a) Traceback (most recent call last): File "&lt;stdin&gt;", line 1, in &lt;module&gt; TypeError: iteration over non-sequence &gt;&gt;&gt; dir(a) ['__doc__', '__module__', 'meth1', 'var1', 'var2', 'var3'] &gt;&gt;&gt; a.__dict__ {} </code></pre>
python
[7]
3,545,761
3,545,762
C++ function problem,
<p>I have this code, but when I compile it with Borland Turbo C++, Turbo C++ say:</p> <blockquote> <p>Error filename.cpp 13: Call of nonfunction in function main()</p> </blockquote> <p>my code is:</p> <pre><code> #include &lt;iostream.h&gt; int reload (int yes, int no) { int reload; cout &lt;&lt; yes &lt;&lt; no; cin &gt;&gt; reload; return reload; } main () { int a, reload = 1; while (reload == 1) { reload (1,0); cout &lt;&lt; "Enter a number: "; cin &gt;&gt; a; } return 0; } </code></pre>
c++
[6]
4,569,075
4,569,076
is there any diff between run a java program with jar or with a package unpacked?
<p>is there any diff between run a java program with jar or with a package unpacked? now i meet a Weird probem. i have a search program.when i run it with a jar,it's ok. when i run it just with package unpacked to jar ,then the gc log is a</p>
java
[1]
1,383,773
1,383,774
Check if a file is writable before writing to it
<p>I'm trying to create a script which will check if a file is writable before writing to it,</p> <p>Making sure the script doesn't exit prematurely.</p> <p>I've gotten this far</p> <pre><code>$meta =stream_get_meta_data($file); while(!is_writable($meta['uri'])){ sleep(rand(0,3)); $meta=stream_get_meta_data($file); echo("sleeping\n"); } $csv = fopen($file, 'a+')or die("can't open file"); </code></pre> <p>When I test the script with $file open, it blocks on the sleeping part even after $file is closed.</p> <p>I'm fairly new to PHP, so there might be a processing paradigm that i'm not aware of.</p> <p>Any help would be very welcome.</p> <p>EDIT : The reason I entered this into a while loop is to continually check if the file is open or not. Hence it should only exit the while loop once the file is finally writable.</p> <p>The sleep is simply to replicate a person trying to open the file.</p>
php
[2]
1,215,804
1,215,805
Android, onPrepareDialog to update parameter-ized string not updating.
<p>This does not seem to be working. The alert dialogs are not even showing a title or message unless I set them in the onCreateDialog method.</p> <pre><code>@Override protected void onPrepareDialog(int id, Dialog dialog) { super.onPrepareDialog(id, dialog); switch(id) { case R.id.catalog_rename_dialog: ((AlertDialog) dialog).setTitle(getString(R.string.catalog_rename_prompt, catalogDb.getColumnById(selectedCatalogId, CatalogDbAdapter.KEY_NAME))); break; case R.id.catalog_delete_dialog: ((AlertDialog) dialog).setMessage(getString(R.string.delete_prompt, catalogDb.getColumnById(selectedCatalogId, CatalogDbAdapter.KEY_NAME))); break; } } </code></pre>
android
[4]
1,729,232
1,729,233
Android Simple way to update MapView without ConcurrentException?
<p>I have a mapview, and some asynctask call, on the asynctask call's end i invalidate my mapview (so i can draw everything, what i need)</p> <p>But I have some buttons on my mapview, thats can update my mapview's onDraw too (invalidate)</p> <p>Sometimes I get a concurrentException because of this. How can I call a function that is wait for an other refresh? </p> <p>Or how can I change this code, to work together?</p> <p>Thanks, Leslie</p>
android
[4]
4,946,136
4,946,137
details of finding 2nd smallest element in unsorted array
<p>Let me make things clear: I want to know more about the implementation of the "best" ALGORITHM how to find 2nd smallest element in array, which is described here:</p> <h2><a href="http://stackoverflow.com/questions/3715935/algorithm-find-index-of-2nd-smallest-element-from-an-unknown-array">Algorithm: Find index of 2nd smallest element from an unknown array</a></h2> <p>First, I am completely clear about the ALGORITHM how to find 2nd smallest element in array. The best solution is O(n+lg(n)-2) which can be achieved by first obtaining the smallest element S and then searching the smallest element of S's competitors. Read here: <a href="http://stackoverflow.com/questions/3715935/algorithm-find-index-of-2nd-smallest-element-from-an-unknown-array">Algorithm: Find index of 2nd smallest element from an unknown array</a></p> <p>What I cannot understand is how to implement it. </p> <p>Especially, after finding the smallest element, how to track back those competitors of the smallest element such that I can find 2nd smallest element in those competitors?</p> <hr> <h2>NO NEED TO SORT. Quicksort is O(nlg(n)) which is worse than O(n+lg(n)-2).</h2> <p>There have been too many people talking about the best solution while nobody actually gave an implementation. Besides, I found the best solution is just theoretical best. It is very hard to implement it following that "best" solution.</p>
c++
[6]
827,474
827,475
How to convert a decimal into time, eg. HH:MM:SS
<p>I am trying to take a decimal and convert it so that I can echo it as hours, minutes, and seconds.</p> <p>I have the hours and minutes, but am breaking my brain trying to find the seconds. Been googling for awhile with no luck. I'm sure it is quite simple, but nothing I have tried has worked. Any advice is appreciated!</p> <p>Here is what I have:</p> <pre><code>function convertTime($dec) { $hour = floor($dec); $min = round(60*($dec - $hour)); } </code></pre> <p>Like I said, I get the hour and minute without issue. Just struggling to get seconds for some reason.</p> <p>Thanks!</p>
php
[2]
1,011,320
1,011,321
e-mail validation on windows form
<p>i am using windows forms.</p> <p>I just want to validate my textbox ( or masked textbox ) for e-mail id.</p> <p>Can any one tell me the idea for that?</p>
c#
[0]
2,040,773
2,040,774
Add a timeout when creating a new Socket
<p>I have a local network with DHCP and a few PCs. One of these should be my Server and get automatically connected to all others (clients). My idea was this: First, I create a server on every client (CServer) that is listening for a client programm from the server (SClient). When the SClient connects to a CServer, the SClient sends the CServer his IP, so he knows there will be the server on this IP. Then after trying all IPs in his IP range (e.g. 192.168.1.xxx), he starts the real server and all the clients connect to the known server IP. But when I try the following, the SClient just freezes at the first IP, when trying to connect to 192.168.1.0. How can i define a timeout or something similar that lets the SClient drop the unsuccessful connection and going on with 192.168.1.1?</p> <pre><code>import java.lang.*; import java.io.*; import java.net.*; class SClient { public SClient() { for(int i = 120; i &lt; 125; i++){ try{ InetAddress addr = InetAddress.getLocalHost(); String addrs = addr+""; String ip = addrs.substring(addrs.indexOf("/")+1); Socket s1 = new Socket("192.168.1." + i, 1254); OutputStream s1out = s1.getOutputStream(); DataOutputStream dos = new DataOutputStream (s1out); dos.writeUTF(ip); dos.close(); s1out.close(); s1.close(); }catch(IOException e){} } } } </code></pre> <p>and</p> <pre><code>import java.lang.*; import java.io.*; import java.net.*; class CServer { public CServer() throws IOException{ ServerSocket s = new ServerSocket(1254); while(true){ Socket s1=s.accept(); InputStream s1In = s1.getInputStream(); DataInputStream dis = new DataInputStream(s1In); String st = new String (dis.readUTF()); System.out.println(st); dis.close(); s1In.close(); s1.close(); } } </code></pre> <p>}</p>
java
[1]
3,863,385
3,863,386
Add an attribute if not already there
<p>How would I add an attribute to an element if that element does not already have that attribute?</p> <pre><code>if (' this does not have class=selected') { $(this).addClass('selected'); } </code></pre>
jquery
[5]
3,230,415
3,230,416
Equivalent is_file() function for URLs?
<p>What is the best way to check if a given url points to a valid file (i.e. not return a 404/301/etc.)? I've got a script that will load certain .js files on a page, but I need a way to verify each URL it receives points to a valid file.</p> <p>I'm still poking around the PHP manual to see which file functions (if any) will actually work with remote URLs. I'll edit my post as I find more details, but if anyone has already been down this path feel free to chime in.</p>
php
[2]
514,007
514,008
Best UI element for displaying results of XML parsing
<p>i am a student and also new to iphone SDK.i want to do xml parsing which has image URL and Data,it is a XML file about news.i have to show it .can i use table view or navigation controller? which is the best way?i have to show images and titles in first page.when i click it,it shows other page to show full news with image. is there any tutorial for what i need?</p>
iphone
[8]
1,616,461
1,616,462
Addding mapview in tablelayout/tablerow at runtime
<p>Respected All. I know how to use map in application. But i have to use map in particular table row at run time. I have used mapview in my another activity. can i use that map view (by id) to show map in that row. Thank You (Vikram Kadam) </p>
android
[4]
3,646,596
3,646,597
How to get comma separated values in td
<p>i getting values from query but i have to place them as comma separated values if there is more than one value I'm looking for output like this: title (x,y) , (x,y) </p> <p>Please help me how can i do this i'm trying in function to get this</p> <pre><code>$cols = array ('test.*', 'user.*', 'count(test_stats.test_public_id) as past_day_views','test_stats.test_public_id', 'test_stats.*' ); $select = $db-&gt;select () -&gt;from ( 'test', $cols ) -&gt;join ( 'user', 'user.user_id = test.user_id', array () ) -&gt;join ( 'test_stats', 'test_stats.test_public_id = test.test_public_id', array ()) -&gt;where ( 'test_stats.updated_on &gt; DATE_SUB(CURDATE(), INTERVAL 1 DAY)' ) -&gt;group ( 'test_stats.test_public_id' ) -&gt;order ( 'title' ); $result = $db-&gt;fetchAll ( $select ); foreach ( $result as $row1 ) { $x = $row1 ['x'] ; $y = $row1 ['y']; $z = $row1 ['title']; } </code></pre>
php
[2]
1,759,086
1,759,087
Why is the physical keyboard not working in my Android app?
<p>In my Android app, the soft keyboard is working properly, but the physical keyboard is <strong>not</strong> working. I could not find out the reason for this. Is it due to any coding mistake of my app, or my phone's issue?</p>
android
[4]
942,394
942,395
repeat each loop every 1 second
<p>For the below code, how do i repeat the each loop every 1 second on hover? So when the mouse is over <code>prevbutton</code> the each loop runs every 1 second?</p> <pre><code>$('.prevbutton').hover(function() { container.animate({'scrollLeft': '-'+scroll}, 5000); $('.parent-container').each(function() { }); }, function(){ container.stop(); }); </code></pre>
jquery
[5]
2,461,042
2,461,043
Android : How get the current Application Context in AsyncTask?
<p>I create an application with several activities and i have an AsyncTask outside any activity which is launched at the begining of the application life. My question is how can i get the current Application Context in the Asynctask class?</p> <p>Thank's for your answers</p>
android
[4]
1,575,674
1,575,675
android: how to know internet connection is available or not in device?
<p>I want to check the Internet connection available or not in device so how can i got this..please give me code for this..</p> <p>thank a lot In advance</p>
android
[4]
4,378,616
4,378,617
java ui component to represent calendar in tabular form
<p>I would like to show the calendar in the tabular form with weeks and days. Any suggestion on which component/library i can use?</p> <p>Thanks in advance, Shags</p>
java
[1]
1,162,854
1,162,855
Is it possible to get detailed help on a given function using the command line?
<p>I am a new Python user :) Is it possible to get detailed help on a given function using the command line ?</p>
python
[7]
5,911,004
5,911,005
Variable undefined
<p>role="manager" and its says that "manager" is undefined.please help.</p> <pre><code> function onSubmitClick(role) { ..... &lt;input type="b utton" class="button" name="btn_Submit" id = "btn_Submit" value="Submit" onMouseOver="showToolTipMessage(T0097);showStatusBarMessage(T0097)" onMouseOut="hideStatusBarMessage()" onFocus="showStatusBarMessage(T0097)" onBlur="hideStatusBarMessage()" onClick="return onSubmitClick(&lt;%=cstr(Role)%&gt;)"&gt; </code></pre>
javascript
[3]
915,040
915,041
Playing video (on iPhone) which has been streamed via a custom protocol?
<p>I need to play video that has been streamed by a custom protocol, <em>not</em> via HTTP live streaming (in fact not via HTTP at all). While I have no problems implementing the protocol, I can't see how to set up a player so that I can just feed the stream to it (and have it decode and display the video) - instead the API always requires I provide a URL.</p> <p>Is there any way to do this?</p>
iphone
[8]
3,678,477
3,678,478
Adding values to Arraylist
<p>Code 1:</p> <pre><code>ArrayList arr = new ArrayList(); arr.add(3); arr.add("ss"); </code></pre> <p>Code 2:</p> <pre><code>ArrayList&lt;Object&gt; arr = new ArrayList&lt;Object&gt;(); arr.add(3); arr.add("ss"); </code></pre> <p>Code 3:</p> <pre><code>ArrayList&lt;Object&gt; arr = new ArrayList&lt;Object&gt;(); arr.add(new Integer(3)); arr.add(new String("ss")); </code></pre> <p>all the above three codes are working fine.. can some one tell me the which is prefered and why.. and why the eclipse compiler always gives warning when type of arguments are not mentioned to the Arraylist.. thanks in advance..</p>
java
[1]
2,987,210
2,987,211
Java library for graphical diff
<p>Is there any Java library that can diff text (in particular XML) files and provide the result as an image (e.g. like Pretty Diff)?</p>
java
[1]
5,816,989
5,816,990
how to pass parameter to javascript in asp.net
<p>I need to pass an url from asp.net load_page to flowplayer javascript function here: <a href="http://flowplayer.org/plugins/streaming/rtmp.html" rel="nofollow">http://flowplayer.org/plugins/streaming/rtmp.html</a></p> <p>How to do that ?</p>
asp.net
[9]
2,424,685
2,424,686
jQuery fade in background image on hover
<p>I have a row of menu buttons, and I need the background-image to be transparent, and then fade in on rollover (hover). can I use jQuery to acheive this?</p> <p><a href="http://jsfiddle.net/craigzilla/JdHWY/" rel="nofollow">http://jsfiddle.net/craigzilla/JdHWY/</a></p>
jquery
[5]
4,290,035
4,290,036
How to know if Android device supports stereo recording?
<p>The new Motorola RAZR supports stereo recording, but many other phones do not. How can I ask Android in a programmatic way if the device supports stereo recording?</p>
android
[4]
5,370,835
5,370,836
Why does Android allocate more memory than needed when loading images
<p>Folks, I don't <em>think</em> that this is a duplicate and is NOT one of those how do I avoid OOMs questions. This is a genuine quest for knowledge so hold off on those down votes please...</p> <p>Imagine I have a JPEG of 500x500 pixels. I load it as ARGB_8888 which is as "bad as it gets".</p> <p>I would expect Android to allocate 500x500x4 bytes = a little under 1MB however, look at a heap dump and you will see that Android allocates significantly more, often factors of 5-10 times greater. </p> <p>You frequently see questions on here about OOMS where the stack trace shows a heap request of say 15MB and it is ALWAYS much larger than is required simply to hold the bytes of the image. The OP usually catches some downvotes then is bombarded with stock answers and comments about using less memory (thanks Romain!) and in scaling. I think there is more than meets the eye here.</p> <p>Anybody know why this is?</p> <p>If there is no apparent answer, I will put together an SSCCE if it helps.</p> <p>PS. I assume that JPEG vs PNG etc is irrelevant since we're talking about the memory usage of the backing bitmap which is simply x times y times BPP - or am I being slow?</p>
android
[4]
2,585,173
2,585,174
Make subcategories in template script
<p>I really need help with a script i have bought, the script has some categories, but i also need sub categories, so i added an extra field in the table traffic_categories. The original traffic_categories has id and category, but i have added sub_id also, so if the category is a main category it has 0 in sub_id, but if the category is a sub category it has the main category id in the sub_id field.. Simple..</p> <p>The problem is the script hava an advanced template system i can´t figure out how works. Here is the script that gets the categories from mysql:</p> <pre><code>$result = mysql_query('SELECT category FROM traffic_categories WHERE sub_id = 0 ORDER BY category ASC;'); $iCat=2; $CONF['categories'] = array(); $TMPL['cats'] = ''; while(list($TMPL['cat']) = mysql_fetch_row($result)) { $TMPL['cath'] = str_replace(' ', '+', $TMPL['cat']); $TMPL['cats'] .= base::do_skin('menu/cats'); $CONF['categories'][] = $TMPL['cat']; $TMPL['last'] = $iCat++ % 4 === 0 ? ' last' : ''; } </code></pre> <p>and here is cats.html:</p> <pre><code>&lt;div class="one-fourth{$last}"&gt; &lt;h5&gt;&lt;a href="/cat/{$cath}"&gt;{$cat}&lt;/a&gt;&lt;/h5&gt; &lt;ul class="categoryList"&gt; Here i want the subcategories--&gt;&lt;li&gt; - &lt;a href=""&gt;&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; </code></pre> <p>and in my frontpage.html where the categories will be showed is just {$cats}.</p> <p>So if someone please can help me show the subcategories inside the list in cats.html where is have written "Here i want the subcategories-->", then i will be really glad, thanks.</p>
php
[2]
5,511,852
5,511,853
Error in PHP file uploading
<p>Now, I am getting another problem. I am trying to upload file with this code :-</p> <pre><code>&lt;form action="up.php" method="post"&gt; &lt;input type="hidden" name="MAX_FILE_SIZE" value="200000" /&gt; Choose a file to upload: &lt;input name="uploadedfile" type="file" /&gt;&lt;br /&gt; &lt;input type="submit" name="submit" value="Upload!"/&gt; &lt;/form&gt; </code></pre> <p>Here is the up.php:-</p> <pre><code>if(!isset($_FILES["uploadedfile"])) die("No file found"); </code></pre> <p>In the above code, it says "No file found". why isn't it having the file?</p>
php
[2]
3,242,098
3,242,099
Sort a list to place an element at the top
<p>I have a <code>List&lt;Vehicles&gt;</code> which contains 4 items:</p> <p>My <code>Vehicles</code> object has 2 properties: <code>VehId</code>, <code>VehName</code></p> <p>The 4 items in my list are: </p> <p>1) <code>VehId : "LOR", VehName : "Lorry"</code></p> <p>2) <code>VehId : "CAR", VehName : "Car"</code></p> <p>3) <code>VehId : "BOA", VehName : "Boat"</code></p> <p>4) <code>VehId : "PLN", VehName : "Plane"</code></p> <p>What I'd like to do is put <code>Car</code> vehicle to the top of the list. How would I do this? By using <code>.OrderBy()</code> or <code>.Sort()</code>? </p>
c#
[0]
3,326,103
3,326,104
using customadapter of listview with viewpagerextension?
<p>any reference/example would be greatly appreciated? trying to use library <a href="https://github.com/astuetz/ViewPagerExtensions" rel="nofollow">https://github.com/astuetz/ViewPagerExtensions</a></p>
android
[4]
5,783,864
5,783,865
Check a list<string> for matches to a userdefined string
<p>I am having difficulties finding a suiteble way as to search a <code>List&lt;&gt;</code> of strings i have for matches to a user specified string, I am not even sure i am going about it in the best way but what i got so far is:</p> <pre><code> // This is the input string. string input = userDefinedStr.ToLower(); //New variable and made into lower cases. for (int i = 0; i &lt; listBox1.Items.Count; i++) { if (listBox1.Items[i].ToString().IndexOf(input, stringComparison.OrdinalIgnoreCase) &gt;= 0) { listBox1.SetSelected(i, true); } else { MessageBox.Show("Sorry, There was no matches found.", "An oupps happend!"); } } </code></pre> <p>The problem is that there can be more the one string in the <code>List</code> that contains the userdefined string and i guess that the best way is actually to display all the <code>List&lt;string&gt;</code> matches in the <code>listBox1</code> instead of just marking the first one found. </p> <p>Or can it be done in another more effective way?!? </p> <p>I am new to C# and coding in general so i dont feel like i know the best way, i have read so many articles and postings but i cant find the one pointing me in the right direction on this.</p>
c#
[0]
3,401,376
3,401,377
Within PHP, how can I make sure a directory as public read access from the web?
<p>I have a bunch of JavaScript files that I want to minify and then cache it to a file. This file is saved to a location I provide as argument.</p> <p>How can I make sure that location has is accessible from the web? </p> <p>What I've tried so far:</p> <pre><code>$test = array ( '/Users/www/htdocs/test/nhecos/cache/test.js', '/Users/www/foo.js' ); $host = 'http://localhost/'; foreach($test as $t) { $url = str_replace($_SERVER['DOCUMENT_ROOT'], $host, $t, $count); $perms = substr(sprintf('%o', fileperms($t)), -4); $p = substr($perms, -1); if ($count &gt; 0 &amp;&amp; $p &gt;= 4) print $url; else throw new \Exception(sprintf("File %s not accessible from Web!", $t)); } </code></pre> <p>This works most of the times but fails if, for instance, that file is in a Virtual Host directory or in a linked folder. Is there any better way? </p> <p><strong>NOTE: my problem is ensuring that</strong> </p> <blockquote> <p>"The files I generate are in a location that is known to the web server and is mapped to a URL."</p> </blockquote>
php
[2]
2,555,406
2,555,407
How to set break points when using jquery chain: obj.appendTo().appendTo().appendTo()?
<p>Jquery chain seems easy to read, however, is it possible to set a break point at one of the calls? </p> <pre><code>obj .appendTo() .appendTo() .appendTo() .doSomething() .doSomething2(); </code></pre> <p>I'm using FireBug in FF.</p>
jquery
[5]
3,572,161
3,572,162
Encoding issue , between windows and linux
<p>This is my code</p> <pre><code>$data['rate_change_with'] = iconv('UTF-8', 'ISO-8859-15//TRANSLIT', $data['rate_change_with']); $rate_change_with_index_array = preg_split('/\s+/', $data['rate_change_with']); </code></pre> <p>on a windows machine it works perfectly. But on ubuntu 12.04 it breaks. preg_split has no effect. $data['rate_change_with'] is something like </p> <pre><code> 3.3 (spaces/tabs) 4.5 (spaces/tabs) 6.5 </code></pre> <p>Help please!</p> <p>Thanks</p> <p>Edit: the spaces and tabs are a 'different' type of space/newline characters mixture, and I am not sure what. Edit2: Not sure if it will help , but here is a screenshot of the target in debugger: <a href="http://i.imgur.com/Mwria.jpg" rel="nofollow">http://i.imgur.com/Mwria.jpg</a></p> <p>Edit3: actual sample: <a href="http://dl.dropbox.com/u/7998366/de.html" rel="nofollow">http://dl.dropbox.com/u/7998366/de.html</a> . The rightmost column is the issue</p> <p>Edit4: changing <code>&amp;nbsp;</code> to spaces doesn't help! what am i doing wrong ??</p>
php
[2]
206,342
206,343
Android: layout background changes when resuming
<p>This is extremely odd behavior. When I load my activity for the first time, everything is fine... the layout background is transparent, as it should be, and which I specified in my xml file.</p> <p>But when I go to another activity and return to the original activity, the background image is set to an image from my res/drawable directory. There is nowhere in my code that the image is referenced, and there is no call to change the background image anywhere. </p> <p>I solved the problem by setting the background color to transparent in onResume(), but I cannot for the life of me, understand why it was doing this. Does anyone have any insights?</p>
android
[4]
83,997
83,998
PHP Form (post) Repeating input in a tabel
<p>I have a form (with post method) that takes the following input:<br> - a certain name<br> - a number<br> - 3 checkboxes </p> <p>All this input gets generated and calculated in a table.(html code within the php)<br> Everything gets properly calculated and displayed in a table. </p> <p><strong>So my question:</strong><br> How do i make it possible after giving all those input to give in more input?<br> Meaning i have made a hyperlink that goes back to the form itself (where i can give the input).<br> So i can give in new data, and after submiting that again the table now contains 2 rows of values insteed of just 1. </p> <p>Not really sure what exactly i need for this. (i use 2 php files, one for the form, then another one where the table gets displayed (and where all my calculations are placed).</p> <p>Regards.</p>
php
[2]
2,435,931
2,435,932
python date appears in last year
<p>How do I do a check in python that a date appears in the last year. i.e. date between now and (now-1 year)</p> <p>Thanks</p>
python
[7]
4,351,637
4,351,638
what exactly are built-in types in Python?
<p>I keep hearing "everything is an object" in both Ruby and Python world. Well, what are built-in functions then? Can someone explain that in layperson English? For example: </p> <pre><code>file=open(abc.txt) </code></pre> <p>open is a built-in function. Is it an object? Is it a method? Of what class?</p> <p>How did we even end-up with <strong>functions in Python</strong> if everything is an object? I mean, shouldn't we be having class, objects, methods and attributes, instead of functions? I thought we had functions in languages like C. Python, Ruby and Java had classes, objects, attributes, methods.</p> <p>In Ruby (<strong>irb</strong>), you could do something like <code>1.class</code> and this will give you <code>Fixnum</code>it will show you which class it belongs to. I don't seem to be able to do this in Python shell. Is there an equivalent?</p> <p>FYI:</p> <ul> <li>I am using Python 2.7</li> <li>relatively new to programming so please use layperson English. For instance, I read in one of the answers "But everything is an object in the sense that it can be assigned to a variable or passed as an argument to a function" --- no idea what that means.</li> </ul>
python
[7]
4,231,138
4,231,139
Display hebrew content in webview android
<p>this is my hebrew content : </p> <pre><code>&lt;string name="test"&gt;בְּרֵאשִׁ֖ית בָּרָ֣א אֱלֹהִ֑ים אֵ֥ת הַשָּׁמַ֖יִם וְאֵ֥ת הָאָֽרֶץ׃&lt;/string&gt; </code></pre> <p>When i display in textview it is display correct format. But when i display in webview it display wrong.</p> <p>I used this but not any effects <code>DIR='RTL' LANG='HE' ALIGN='JUSTIFY'</code> in html. I want to display in webview. </p>
android
[4]
5,857,998
5,857,999
jQuery pass value class
<pre><code>$(".hidee2").click(function() { var type = $(".st").val(); } &lt;form action="" method="POST"&gt;&lt;input type="hidden" class="st" value="st"&gt;&lt;div class="button"&gt;Room Status : Accepting Reservation &lt;br /&gt;&lt;span&gt;&lt;span&gt;&lt;a class="hidee2"&gt;Book Now!&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/form&gt; &lt;form action="" method="POST"&gt;&lt;input type="hidden" class="st" value="st2"&gt;&lt;div class="button"&gt;Room Status : Accepting Reservation &lt;br /&gt;&lt;span&gt;&lt;span&gt;&lt;a class="hidee2"&gt;Book Now!&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/form&gt; &lt;form action="" method="POST"&gt;&lt;input type="hidden" class="st" value="st3"&gt;&lt;div class="button"&gt;Room Status : Accepting Reservation &lt;br /&gt;&lt;span&gt;&lt;span&gt;&lt;a class="hidee2"&gt;Book Now!&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/form&gt; </code></pre> <p>How do i get which book now! link user click? because i need to pass over the st value? is there any way to achieve this using jquery? currently, only st value is passed over</p>
jquery
[5]
5,611,340
5,611,341
selecting from Jquery success result
<p>I'm trying to update a part of a page after the success of an asynchronous post.</p> <p>So I have:</p> <pre><code>success: function (data, status, xhr) { var elementName = "#div" + gridName; var findResult = $(data).find(elementName); $(elementName).html($findResult); </code></pre> <p>Now when I view data the HTML looks like:</p> <pre><code>&lt;div class="t-grid-header"&gt; &lt;div class="t-grid-header-wrap"&gt; &lt;table cellspacing="0"&gt; </code></pre> <p>but when I inspect the HTML from findResult it looks like:</p> <pre><code>&lt;DIV class=t-grid-header&gt; &lt;DIV class=t-grid-header-wrap&gt; &lt;TABLE cellSpacing=0&gt; </code></pre> <p>This is not 'good' Html so I can't use it. So how do I get good HTML. findResult.html() doesn't work because the call is too late. The conversion has already happened.</p> <p>How do I proceed?</p>
jquery
[5]
4,119,809
4,119,810
Error while calling next activity in android?
<p>this is my first activity code:</p> <pre><code>public class hello extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Button button = (Button) findViewById(R.id.imageButton1); button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // Perform action on click Intent i = new Intent(hello.this,Selectmsg.class); startActivity(i); } }); } } </code></pre> <p>following is my next activity code:</p> <pre><code>public class Selectmsg extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main1); } } </code></pre> <p>but i am occurring error.it closing forcefully.,its not working.i just want to call next activity.and i also written driver for next activity in Androidmanifest.so please help me to remove error.. Thanks in Advance--</p>
android
[4]
5,534,274
5,534,275
set dropdownlist selectedIndex in gridview
<p>I have a grideview that is being populated by an ObjectDataSource. In the EditItemTemplate, I have a dropdownlist which gets populated thru the code behind on the RowDataBound event:</p> <pre><code> ddStates.DataSource = snm.getStates(); ddStates.DataTextField = "State"; ddStates.DataValueField = "StateID"; ddStates.DataBind(); </code></pre> <p>Now, what i would like to do is set the selected index of my dropdownlist to the current value for the row from the objectDataSource. How do I get the StateID from the ObjectDataSource?</p> <p>Thanks, I have been running in circles on this one.</p>
asp.net
[9]
4,824,749
4,824,750
jquery append to element when it appears with ajax displaytag
<p>Lets say I may (but also may not) have an element with class <code>order</code> in my DOM. It maybe create on page load but also, after successful ajax request. My question is, how can I add some live event, that will append something to my element based on it class?</p> <p>Flow would be like this:</p> <p>1.Opening page, jQuery searchs for elements with class <code>order</code>, if found, appends something to them (for this question lets say its text <code>"text string"</code><br/> 2.I do an ajax request<br/> 3.After ajax request jQuery searchs again for class <code>order</code> and append if found</p> <p>There is one condition, I DON'T want to trigger any function searching for elements after ajax request, I'd prefere some magic trick with <code>.live()</code> function, if it is possible of course.</p> <p><strong>EDIT</strong> Exact problem</p> <p>What I was really trying to achive, is appending an img to certain class within newly loaded DOM. <br/>From the beginning:</p> <ol> <li><p>I tried to implementing sortable/paginable table with displaytag and ajax.</p></li> <li><p>Then adding (also Ajax) search list filtering.</p></li> <li><p>After table is reloaded with Ajax, append images (up or down icon depending on sorting type)</p></li> </ol> <p>See my answer for results</p>
jquery
[5]
1,094,514
1,094,515
How to determine the bit order allocation at compile time?
<p>as we all known, for some compilers:</p> <pre><code>struct T{ char bits: 4; // 3:0 }; </code></pre> <p>and for others:</p> <pre><code>struct T{ char bits: 4; // 7:4 }; </code></pre> <p>since this is not specified by the standard. ( I do think this (the arithmetic meaning) should be specified by the standard, and the actual physical allocation is another issue that can't be specified. )</p> <p>However, I want my code to be more generic, so I tried:</p> <pre><code>union helper{ unsigned char b:1; unsigned char c; constexpr helper(unsigned char i): c(i){} }; constexpr int lsb_defined_at_top(){ return helper(1).b;} enum{ LSB_AT_DEFINED_AT_TOP = lsb_defined_at_top() }; </code></pre> <p>but the compiler (gcc 4.7.2) complains:</p> <p>error: accessing 'helper::b' member instead of initialized 'helper::c' member in constant expression</p> <p>I wonder is there any way to determine this at compile time ...</p>
c++
[6]
69,262
69,263
PHP Twitter Style Date
<p>I am wanting to format my date with a Twitter style format however all the examples only have the x hours ago. What I would like...if possible, is:</p> <pre><code>- X min ago - X hours ago - Yesterday - Thursday (or other days) - 17 December </code></pre> <p>X min/hour ago and yesterday are pretty self explanatory but the day should be used if the date is greater than today and yesterday and the day falls within the current week (week starting Sunday).</p> <p>The 17 December is if the date is greater than any day in the current week.</p> <p>I am hoping this can be done. Cheers</p>
php
[2]
3,512,407
3,512,408
how to get running applications icon on android programmatically
<p>Below here is my code but i am getting default android launcher icon for all running applications:</p> <pre><code>PackageManager pm = getPackageManager(); ActivityManager am1 = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); List&lt;RunningTaskInfo&gt; processes = am1.getRunningTasks(Integer.MAX_VALUE); if (processes != null) { for (int k = 0; k &lt; processes.size(); k++) { // String pkgName = app.getPackageName(); String packageName = processes.get(k).topActivity .getPackageName(); Drawable ico = null; try { String pName = (String) pm.getApplicationLabel(pm .getApplicationInfo(packageName, PackageManager.GET_META_DATA)); ico = pm.getApplicationIcon(pName); } catch (NameNotFoundException e) { Log.e("ERROR", "Unable to find icon for package '" + packageName + "': " + e.getMessage()); } icons.put(processes.get(k).topActivity.getPackageName(),ico); } </code></pre>
android
[4]
4,533,687
4,533,688
Accessing the value of a variable by its name as string in Java
<p>I have a string containing the variable name. I want to get the value of that variable.</p> <pre><code>int temp = 10; String temp_name = "temp"; </code></pre> <p>Is it possible to access the value <code>10</code> by using <code>temp_name</code>?</p>
java
[1]
2,116,636
2,116,637
Script causing 500 Internal Server Error
<p>My site has been suffering "500 Internal Server Error" often of late, and host has advised that this bundle.css.php script might be the reason why ...</p> <pre><code>&lt;?php ob_start('ob_gzhandler'); header('Content-Type: text/css'); $files = split(",",$_GET['files']); foreach($files as $key=&gt;$val){ if(file_exists($val.'.css')){ include_once($val.'.css'); }else{ echo "\n\n/*** File \"$val\" does not exist. ***/\n\n"; } } ?&gt; </code></pre> <p>In the words of my host ...</p> <p>"It is trying to buffer all of output into ob_gzhandler. It is taking a very insecure list of parameters passed in GET variable 'files', and is then trying to include those files into the output. I'm not sure exactly what list of parameters is being passed, but I suspect there is a bug somewhere in your scripts that is passing a large array of file names to this script, and thus trying to build a buffered object that is too large."</p> <p>This is well beyond my expertise, so any advice to fix the problem would be much appreciated. Many thanks.</p> <hr> <p>UPDATE</p> <p>The error log is full of lines such as ...</p> <p>[Mon Apr 23 15:44:41 2012] [error] [client xx.xx.xx.xx] (12)Cannot allocate memory: couldn't create child process: /opt/suphp/sbin/suphp for /home/xxxxxy/public_html/xxxx.php, referer: <a href="http://www.xxxxxxx.com/wp-content/themes/xxx/style.css" rel="nofollow">http://www.xxxxxxx.com/wp-content/themes/xxx/style.css</a></p>
php
[2]
4,586,153
4,586,154
Setting location of the form using c#
<p>I have a form which has only tab control in it. I want to fix the location of the form on windows desktop according to the screen size of the users pc.</p> <p>The form looks like windows task bar and it should be docked on top of windows desktop. For this i set dock = top property in my form. But still it is not perfectly on top.</p> <p>How to over come these melodramatically.</p>
c#
[0]
2,072,061
2,072,062
Creating a wchar to multibyte char function
<p>The libc library I'm currently using is missing wctomb() so I'm looking to come up with a replacement implementation. What are some complexities I should beware of? Can I simply grab each byte in the wchar and stick them inside an char array?</p>
c++
[6]
1,028,566
1,028,567
An extension method for Session variables
<p>I created the following extension method:</p> <pre><code> public static bool HasHostAndUrl(this HttpSessionStateBase session) { return session["CurrentUrl"] != null &amp;&amp; session["CurrentHost"] != null; } </code></pre> <p>I also have the following that appears in my code. Is it possible I could make this into an extension method also:</p> <pre><code>string.Format("http://{0}{1}", Session["CurrentHost"], new Uri((string)Session["CurrentUrl"]).PathAndQuery) </code></pre>
c#
[0]
1,361,129
1,361,130
How can I recognize whether it is a class or interface in java by seeing the name?
<p>Hi I like to know how can I recognize whether it is a class or interface by seeing the name .. For example all class name starts with capital letters.. method name starts with small name.. Is there any specific way to recognize it?</p> <p>Thanks</p>
java
[1]
3,611,177
3,611,178
Intent.getAction() is throwing Null + Android
<p>I have written BroadcastReceiver for sort of Alarm application. In onReceive method I am reading Intent.getAction(). <strong>It is running well in all of the versions *<em>except in SDK version 1.5 where it throws null pointer exception</em>*</strong>. I am setting the action in another activity where I am calling broadcastReceiver. Please help me out with this. Below is the code snippet for both receiver and activity classes,</p> <p><strong>ProfileActivity.java</strong></p> <hr> <pre><code>public static final String STARTALARMACTION = "android.intent.driodaceapps.action.STARTPROFILE"; public static final String STOPALARMACTION = "android.intent.driodaceapps.action.STOPPROFILE"; AlarmManager alarmMan = (AlarmManager) getSystemService(Context.ALARM_SERVICE); Intent startIntent = new Intent(this,AlarmReceiver.class); startIntent.setAction(STARTALARMACTION); Intent stopIntent = new Intent(this,AlarmReceiver.class); stopIntent.setAction(STOPALARMACTION+intentposition); </code></pre> <h2><strong>AlarmReceiver.java</strong></h2> <pre><code>@Override public void onReceive(Context context,Intent intent){ String intentAction = intent.getAction(); Log.d(TAG,"Intent:"+intentAction); **//throwing null** </code></pre> <p>After getting the error I tried my luck by giving the actions in of .manifest file. But no use. </p> <p>Please help me.</p> <p>Thanks.</p>
android
[4]
206,343
206,344
How many days elapsed of the current year
<p>I want to get number of days elapsed from the current years Jan 1st to today date. I am making a unique id and I want to use it as part of the id. I want number to fixed to three digits with leading zeros. Plz help. </p> <p>e.g.</p> <p>Today : 2012-2-27 Then number of days elapsed is 057. </p>
php
[2]
5,081,277
5,081,278
Spiral Number pattern in java
<p>I need to create these patterns in java according to how-many numbers the user enters: like this if user enters 3:</p> <pre><code>1 2 3 ------------&gt; 8 9 4 |-------&gt; | 7 6 5 &lt;-----------| </code></pre> <p>if user enters 4:</p> <pre><code> 1 2 3 4 12 13 14 5 11 16 15 6 10 9 8 7 </code></pre> <p>if user enters 5:</p> <pre><code> 1 2 3 4 5 16 17 18 19 6 15 24 25 20 7 14 23 22 21 8 13 12 11 10 9 </code></pre> <p>and so on..</p>
java
[1]
4,625,539
4,625,540
Getting screen height before first display?
<p>I have a ListView. I populate it with 8 items, that's all that fits vertically on the G1. Some of my users are saying the Droid has a taller screen height, and so I can probably add one or two more items to the ListView to take up the additional space provided.</p> <p>How could I measure the available height the screen offers at startup, before the UI is displayed? If I see the height can fit more than 8 items, I'd like to add one or two more rows,</p> <p>Thanks</p>
android
[4]
1,811,653
1,811,654
Regarding Good C# Book for Beginner
<blockquote> <p><strong>Possible Duplicates:</strong><br> <a href="http://stackoverflow.com/questions/477748/what-are-the-best-c-net-books">What are the best C# .NET books?</a><br> <a href="http://stackoverflow.com/questions/3476074/book-about-c-for-a-beginner">Book about c# for a beginner</a> </p> </blockquote> <p>I am a beginner in C# would need a good book. Please advise.</p>
c#
[0]
645,894
645,895
$(document).ready called inside an external function?
<p>I saw some jquery code on the Net somewhere, that took this form :</p> <pre><code>&lt;script&gt; function doSomething(message) { $(document).ready(function(){ alert(message); }); }; &lt;/script&gt; </code></pre> <p>i.e. an external function ("doSomething") which has $(document).ready inside it. I'm confused because isn't the code under $(document).ready triggered when the DOM is loaded ? Its like having an event handler inside a function (?). Does this form of code make sense to anyone ? Thanks.</p>
jquery
[5]
1,542,018
1,542,019
Calculating an average, minimum, and maximum, from an imported file (.txt)
<p>I have a project where I need to read in data from a .txt file and run some calculations on it. No arrays allowed.</p> <p>The data in the file looks like this.</p> <p>firstname lastname age scores</p> <p>example</p> <p>Brian Moore 55 8 4 3 6 13 2 4 7</p> <p>I need to print the data with just the initials of the person (first two letters of each name), and find an average for the scores.</p> <p>This is what I started with, but I am really just stumped at this point, which means getting started. I feel like if I can get one line down, it's just a matter of making loops to create the rest.</p> <pre><code> int scoreCounter = 1; int scoreSum = 1; while (inputOne.hasNext()) { int scoreList = inputOne.nextInt(); System.out.println(scoreList); scoreSum = scoreSum + scoreList; scoreCounter++; } System.out.println("Average: " + (scoreSum/scoreCounter)) } </code></pre>
java
[1]
5,258,266
5,258,267
Generate a form from a poco object
<p>Say you had a config object </p> <pre><code>public class MyConfig{ public int PageSize{get;set;} public string Title{get;set;} } </code></pre> <p>and you want to automatically generate a asp.net form to edit the properties on this object.</p> <p>Do you know of any frameworks to do this automagically? </p> <p>I know of MS Dynamic data, but seems I need to have the whole stack (database, linq, objects) to get this up and running. So I was thinking of something simpler..</p>
asp.net
[9]
1,342,993
1,342,994
How do I declare and access an array of objects in JavaScript?
<p>I have the following code, with the intention of defining and using a list of objects, but I get an 'undefine' for <code>post_title</code>. What am I doing wrong? I don't want to name the array as a property of an object, I just want a collection/array of objects.</p> <pre><code>var templates = [{ "ID": "12", "post_title": "Our Title" } , { "ID": "14", "post_title": "pwd" }]; function templateOptionList() { for(var t in templates) { console.log(t.post_title); } } $(function () { templateOptionList(); }); </code></pre>
javascript
[3]
2,675,111
2,675,112
PHP: compute 2 variables product
<p>how can I compute the product between these 2 quantities in php ?</p> <p>This is what I've tried, but it doesn't work</p> <pre><code>&lt;?php echo (uc_price($price_info, $context) * $product-&gt;qty); ?&gt; </code></pre> <p>thanks</p>
php
[2]
3,397,709
3,397,710
ASP Security Exception: Same but different
<p>Raking my brain and I have tried many of the "solutions" found online. Basically we are demoing this application from a vendor and the initial install worked fine. The application is actually four different applications. On our Windows server we have our main site, with four applications inside of it for the vendor. All of these were using the default application pool. Everything was working.</p> <p>They asked us to updated the software and things went to hell. Updating involved deleting all the old files and replacing them with the new ones they sent us and then updating our SQL database. We we finished two of the applications had the error:</p> <pre><code>Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. </code></pre> <p>I have found many answers regarding this. Change the Load User Profile to ture, tried that, Unblock all the dll files, tried that. Mess with the trust level, tried that. I have since separated the applications into their own pools (at the advice of the vendor but they seem to have no clue) and after messing with it a ton, I now have three of the applications running, oddly enough one of the ones initially running is the one that is not running. The thing is the application was running initially, all we did was updated the files to newer versions.</p> <p>My question I guess is where is the System.Web.AspNetHostingPermission called? Is that just a general level Asp application thing? I am pulling out my hair about this and we might just have to tell the vendor to take their product elsewhere if we can't get it running, but I am 99% sure it's a server setup issue. Thing is, I've never dealt with software where the update process is, delete all your files and replace them with the ones in this zip file.</p> <p>Any thoughts on this. I feel like I have tried most of the obvious solutions but need some deeper thoughts.</p>
asp.net
[9]
2,313,184
2,313,185
Draw A Custom Table In Windows Forms
<p>I want to draw a custom table to be a way similar to this one in the picture</p> <p><img src="http://i.stack.imgur.com/OCyeL.png" alt="enter image description here"></p> <p>I have tried the TableLayoutPanel but i can't get something similar to this one, So your help would be very appreciated and thanks in advance.</p>
c#
[0]
4,203,378
4,203,379
how can i do login google plus in my android application
<p>i am new in android can any one tell me how can i do login google plus in my android application. i want to do a user can login with google plus, facebook and other </p> <p>i want to know how the user login in google plus i download the google API from <a href="https://developers.google.com/+/downloads/" rel="nofollow">https://developers.google.com/+/downloads/</a> th google API Google APIs Client Library for Java (beta) is it right API? if yes how can i implement this API in my Application.</p>
android
[4]
2,471,041
2,471,042
standalone application in python
<p>I wanted to know how can I make standalone application in python. Basically what I am doing right now is I have a template.tex file and my script generate the pdf by giving some input values. So I have to make exe file for windows and same for linux. I can use cx_freeze for creating exe file. But my problem is most of people do not contain latex on their computer. SO how can I make latex get install when I first run my exe. Basically how to make make file.</p> <p>Thanks</p>
python
[7]
2,236,882
2,236,883
How to set to user account value "must not enter a user and password to use this computer" through c# code
<p>How to set to user account value "must not enter a user and password to use this computer" when power up the computer the user wouldn't have to insert his user name &amp; password through c# code</p>
c#
[0]
1,951,237
1,951,238
jquery .remove not working
<p>So I'm trying to port a web site I wrote in php to java. And I can't figure out why my jquery isn't working in java. Here's a trimmed down function that I'm trying to get working. When I click on a button I was it to remove a div. I know my function is being called because of the alert I've put in there but the jquery is not working.</p> <pre><code>function divClose() { alert('close div'); $("div.flashMessage").remove(); $("div.flashMessage").fadeOut("slow", function() { alert('close div'); $("div.flashMessage").remove(); }); } </code></pre>
jquery
[5]
4,742,377
4,742,378
Collections vs Arrays regarding sort()
<p>Collections vs Arrays regarding sort() What is the difference between these two regarding sort() method? I know Arrays' sort() is using binary search for sort(), what about Collections'? And how to choose which to use? Thanks!</p>
java
[1]
5,893,200
5,893,201
android add ImageView selector programmatically
<p>I want to change ImageView background (in my case gradient color) using selector state programmatically not by using xml file.</p> <p>I want pressed and default state to my ImageView</p> <p>For creating gradient background I use this code:</p> <pre><code> GradientDrawable gd = new GradientDrawable( GradientDrawable.Orientation.BOTTOM_TOP, new int[] {Color.parseColor(startColour), Color.parseColor(endColour)}); </code></pre> <p>How can I implement selector for this?</p> <p>Thanks</p>
android
[4]
2,040,669
2,040,670
How can i delete image file in external storage after email sent?
<p>i am storing image in External storage using MediaStore,and send email with attach that image,image saved and sent email with attachment is working fine,i want to delete that image in external storage after mail sent.anybody knows,please give sample code for me..</p> <p>Thanks All,</p>
android
[4]
3,410,773
3,410,774
Can I have an application always open on Android?
<p>I don't know much about Android multitasking but I thought I'd ask the question before I attempt my project.</p> <p>Is there a way I can program an Android application (aimed at Android 4.0+ only) to always be open in the background and keep all the network connections alive and the UI "drawn" so that when I open it, it ALWAYS opens instantly and I can use it instantly even if the tablet is doing something else?</p> <p>Thanks.</p>
android
[4]
5,692,976
5,692,977
Assigning values to elements of list
<p>When I have a for loop:</p> <pre><code>for row in list: row = something_or_other </code></pre> <p>It seems that sometimes I can assign a value (or append/extend etc.) directly to <code>row</code> and the <code>list</code> changes accordingly, and sometimes I have to do something roundabout like:</p> <pre><code>for row in list: list[list.index(row)] = something_or_other </code></pre> <p>What gives?!?</p>
python
[7]
4,835,660
4,835,661
Replacing tokens in a string from an array
<p>Let's say I have a string</p> <blockquote> <p>This $0 is $2 $1. Still, \$$3 is a lot to pay for a puppy.</p> </blockquote> <p>and an array of replacements</p> <pre><code>array('puppy', 'cute', 'ridiculously', '1300') </code></pre> <p>What would be the cleanest way to replace the tokens in the string with the corresponding items in the array, letting me backslash-escape the token character (in this case <code>$</code>)? I also want to replace unmatched tokens with the empty string.</p>
php
[2]