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
2,080,391
2,080,392
Where online can I find a good practice test on Java
<p>Hello I have a test on Java next week , and i'm looking for a practice test to try out. For example <a href="http://www.proprofs.com/quiz-school/story.php?title=csci-1302-final-demo" rel="nofollow">http://www.proprofs.com/quiz-school/story.php?title=csci-1302-final-demo</a></p> <p>If you know any good Java practices test, please let me know. I'm looking for multiple-choice test on <strong>Array Based Lists, Stacks and queues, Linked lists, Binary trees, and AVL Trees.</strong></p>
java
[1]
1,331,577
1,331,578
PHP Parser for HTML File
<p>I want a PHP Function which parse the html tags and insert into my db..</p> <p>and in html page their are link with in link means 1 link have sublink and they crawl the data in the sublink also and insert into my database.</p> <p>Please code some function how would i do that i am new on that</p>
php
[2]
5,948,856
5,948,857
Convert const char* to wstring
<p>I'm working on a native extension for a zinc based flash application and I need to convert a <code>const char*</code> to a <code>wstring</code>.</p> <p>This is my code:</p> <pre><code>mdmVariant_t* appendHexDataToFile(const zinc4CallInfo_t *pCallInfo, int paramCount, mdmVariant_t **params) { if(paramCount &gt;= 2) { const char *file = mdmVariantGetString(params[0]); const char *data = mdmVariantGetString(params[1]); return mdmVariantNewInt(native.AppendHexDataToFile(file, data)); } else { return mdmVariantNewBoolean(FALSE); } } </code></pre> <p>But <code>native.AppendHexDataToFile()</code> needs two <code>wstring</code>. I'm not very good with C++ and I think all those different string types are totally confusing and I didn't find something useful in the net. So I'm asking you guys how to do it.</p> <p><strong>Edit</strong>: The Strings are UTF-8 and I'm using OSX and Windows XP/Vista/7</p>
c++
[6]
1,174,734
1,174,735
Android: Internet Accesing Application
<p>I am making an application that fetches data from internet like web service,so it requires internet connection.</p> <p>So when i first click on my application, If internet connection is not available it should show me dialog that Internet connection not available get it connected.And if connection is available then it should be able to work fetch data from internet.</p> <p>Can anybody guide me how to check if internet connection is available or not? </p>
android
[4]
469,881
469,882
code problem finding id and index
<p>new to programming and android, so I really have no idea what im doing. can anyone tell me why this code returns incorrect values of -1 for index and a 10 digit number for id, when I clearly assign an id and the index should not be -1 because its 0 based??</p> <p>I would think that the problem is somewhere in the code that gets the focused view, but ive tried findFocus and getCurrentFocus, and both return the same thing. Here is the code, thanks!</p> <pre><code>llmain = (LinearLayout) findViewById(R.id.linearLayoutMain); linflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); int pos = 0; View myView = linflater.inflate(R.layout.action, null); myView.setId(pos); pos++; llmain.addView(myView); myView.requestFocus(); View v = getCurrentFocus(); if(v instanceof EditText) { id = v.getId(); index = llmain.indexOfChild(v); Context context = getApplicationContext(); CharSequence text = "index is:" + index + "id is:" + id; int duration = Toast.LENGTH_SHORT; Toast toast = Toast.makeText(context, text, duration); toast.show(); } } </code></pre>
android
[4]
2,054,811
2,054,812
How to replace the image of the back button entirely with different image?
<p>Below is my coding </p> <pre><code>// Navigation logic may go here -- for example, create and push another view controller. NextViewController *nextViewController = [[NextViewController alloc] initWithNibName:@"NextViewController" bundle:nil]; [self.navigationController pushViewController:nextViewController animated:YES]; [nextViewController release]; UIImage *backImage=[UIImage imageNamed:@"backbutton.png"]; UIBarButtonItem * backBarButtonItem = [[UIBarButtonItem alloc] initWithImage:backImage style:UIBarButtonItemStylePlain target:nil action:nil]; self.navigationItem.backBarButtonItem = backBarButtonItem; [backBarButtonItem release]; } </code></pre>
iphone
[8]
4,300,131
4,300,132
How to reload a java application?
<p>I want to have a button in my application that simply reloads the application. </p> <p>Essentially, I just want to re-run the JAR and System.exit() - but I don't want to do this using Runtime.exec() because I need it to work on multiple OS.</p> <p>I can't really come up with anything.</p>
java
[1]
32,296
32,297
How to get application name and package name?
<p>i wand to get application name which is stored into SD card or phone only thanks in advance....</p>
android
[4]
5,300,886
5,300,887
not supported character in php
<p>I'm having a problem in inserting data in php. It sometimes create a character like a black diamond with a question mark. <img src="http://i.stack.imgur.com/CqcYf.png" alt="enter image description here"></p> <p>do you have any idea how can i fix it?</p>
php
[2]
3,294,348
3,294,349
Does PHP evaluate variables when a function is defined?
<p>I am creating a multipage form in PHP, using a session. The <code>$stage</code> variable tracks the user's progress in filling out the form, <strong>(UPDATE) and is normally set in $_POST at each stage of the form.</strong></p> <p>On the second page (stage 2), the form's submit button gets its value like this:</p> <pre><code>echo '&lt;input type="hidden" name="stage" value="'; echo $stage + 1; echo '" /&gt;; </code></pre> <p>That works fine - <code>$stage + 1</code> evaluates to 3 if I'm on page 2. But since I'm doing this more than once, I decided to pull this code out into a function, which I defined at the top of my code, before <code>$stage</code> is mentioned.</p> <p>In the same spot where I previously used the code above, I call the function. I have verified that the function's code is the same, but now <code>$stage + 1</code> evaluates to 1.</p> <p><strong>Is PHP evaluating my variable when the function is defined, rather than when it's called? If so, how can I prevent this?</strong></p> <h3>Update 1</h3> <p>To test this theory, I set <code>$stage = 2</code> before defining my function, but it still evaluates to 1 when I call the function. What's going on?</p> <h3>Problem Solved</h3> <p>Thanks to everyone who suggested variable scope as the culprit - I'm slapping my forehead now. <strong><code>$stage</code> was a global variable, and I didn't call it <code>$GLOBAL_stage</code></strong>, like I usually do, to prevent this sort of problem.</p> <p>I added <code>global $stage;</code> to the function definition and it works fine. Thanks!</p>
php
[2]
5,475,235
5,475,236
Extention method for a Page control - error
<p>I've written a small extention method for a page control, to recursively search for a control. But I get the "Object reference not set to an instance of an object" exception.</p> <p>And it seems page.Controls only has 1 control and on this control I et this exception.</p> <p>Anyone has any idea?</p> <p>Here is the code:</p> <pre><code>public static Control FindControlRecursive(this Page page, string id) { return Execute(page, id); } private static Control Execute(Control root, string id) { if (root.ID.Equals(id)) return root; ControlCollection controls = root.Controls; foreach (Control ctrl in controls) { Control FoundControl = Execute(ctrl, id); if (FoundControl != null) return FoundControl; } return null; } } </code></pre> <p><strong>Update</strong> Now I have another error: Error occured: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index ...</p> <p>But this one throws somewhere in middle of the looping.</p>
c#
[0]
2,974,649
2,974,650
Problems in svn log command in python script
<p>I am executing an "svn log" command using os.popen3 in python as follows: stdin,stdout,stderr = os.popen3('svn log -r ' + txnNo) I am able to retrieve the commit log message if I commit via cmdline. But if I commit from tortoiseSVN from windows Explorer I get an empty commit log message.</p> <p>any help would be appreciated.</p> <p>thanks in advance</p>
python
[7]
3,577,131
3,577,132
discover path of python module
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/247770/retrieving-python-module-path">Retrieving python module path</a> </p> </blockquote> <p>Suppose I have code in 3 python files. x.py, y.py, z.py. </p> <p>x calls y and y calls z. In the code in z.py, I want to know what directory x.py is in.</p> <p>Is there a function that will tell me this?</p> <p>EDIT forget z.py. I just want y.py to print out the path of x.py.<br> EDIT </p> <p>Note that the system has 30 different files all named x.py located in different directories.</p>
python
[7]
1,453,464
1,453,465
how to modify the document selection in javascript?
<p>I wanna modify the document selection (user currently selected by mouse or keyboard), how to do it in a cross browser way?</p>
javascript
[3]
1,371,907
1,371,908
explain pattern of rebinding globals to locals in javascript
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/2716069/how-does-this-javascript-jquery-syntax-work-function-window-undefined">How does this JavaScript/JQuery Syntax work: (function( window, undefined ) { })(window)?</a> </p> </blockquote> <p>i see this pattern in the <a href="http://www.dustingetz.com/client-side-designer-templates/assets/javascripts/jquery-1.8.2.js" rel="nofollow">jquery source code (line 13)</a>, where they rebind 'window' and 'undefined' to locals:</p> <pre><code>(function(window, undefined) { window.something = 42; var dummy = 42 === undefined; }(window)); </code></pre> <p>i think rebinding 'window' to a local is a strict mode thing (prevents accidental access to window) - but look at how they are binding <code>undefined</code> to a local as well. why?</p>
javascript
[3]
441,870
441,871
Using jQuery, show a div if only two or more checkboxes are checked
<p>I need to show a div if two or more checkboxes are checked using JQuery only.</p> <p>How can I achieve this?</p>
jquery
[5]
5,253,106
5,253,107
C# Method Overloading Issue, string string[] conversion
<p>I'm trying to get the below to work as follows. name(something) adds something to the list. and then name() retrieves the values. But I'm having some problems and was hoping one of you guys knows what's up.</p> <pre><code>public class PlayerSettings { public List&lt;string[]&gt; Players = new List&lt;string[]&gt;(); public void Name(string input) { string[] addname = new string[1]; addname[0] = input; Players.Add(addname); } public string[] Name() { foreach (string[] Player in Players) { return Player[0]; } } } </code></pre> <p>cannot implicitly convert type string to string[] error on the line below.</p> <pre><code>return Player[0]; </code></pre>
c#
[0]
5,962,763
5,962,764
Accurate trig in python
<p>Straight to the chase I want to create a function which calculates the length of a step.</p> <p>This is what I have:</p> <pre><code>def humanstep(angle): global human human[1]+=math.sin(math.radians(angle))*0.06 human[2]+=math.cos(math.radians(angle))*0.06 </code></pre> <p>So if the angle is 90 then the x value (human[1]) should equal 0.06 and the y value equal to 0.</p> <p>Instead the conversion between radians and degrees is not quite perfect and these values are returned.</p> <pre><code>[5.99999999999999, 3.6739403974420643e-16] </code></pre> <p>Is there anyway to fix this?</p>
python
[7]
5,066,056
5,066,057
Am I missing something? I keep outputting "No file found!"
<pre><code>void getBookData(bookType books[], int&amp; noOfBooks) { ifstream infile; string file = "bookData.txt"; infile.open(file.c_str()); if (infile.fail()) { cout &lt;&lt; "No file found!" &lt;&lt; endl; infile.clear(); } while (true) { string line; getline(infile, line, '\r'); if (infile.fail()) { break; } cout &lt;&lt; "Line: " &lt;&lt; line &lt;&lt; endl; } infile.close(); } </code></pre> <p>I've tried putting the file in every location I can think of, but somehow it's not loading in. Or, more likely, I'm doing something else wrong. This isn't anything like what the end result of my code is supposed to be like, right now I'm just trying to read out my file line by line.</p>
c++
[6]
934,328
934,329
Data capture from optical mark reader in java
<p>i need to develop software for data capture optical mark reader sheet .please suggest me how to develop and if any third party jar is available help me </p> <p>Thanks in advance</p> <p>Aswan</p>
java
[1]
1,436,450
1,436,451
better performance for algorithm
<p>I have something like this:</p> <pre><code>using (SqlDataAdapter a = new SqlDataAdapter(query, c)) { // 3 // Use DataAdapter to fill DataTable DataTable t = new DataTable(); a.Fill(t); string txt = ""; for (int i = 0; i &lt; t.Rows.Count; i++) { txt += "\n" + t.Rows[i][0] + "\t" + t.Rows[i][1] + "\t" + t.Rows[i][2] + "\t" + t.Rows[i][3] + "\t" + t.Rows[i][4] + "\t" + t.Rows[i][5] + "\t" + t.Rows[i][6] + "\t" + t.Rows[i][7] + "\t" + t.Rows[i][8] + "\t" + t.Rows[i][9] + "\t" + t.Rows[i][10] + "\t" + t.Rows[i][11] + "\t" + t.Rows[i][12] + "\t" + t.Rows[i][13] + "\t" + t.Rows[i][14] + "\t" + t.Rows[i][15] + "\t" + t.Rows[i][16] + "\t" + t.Rows[i][17] + "\t" + t.Rows[i][18] + "\t" + t.Rows[i][19]; } } </code></pre> <p>I need this tabs between columns to generate txt file later. Problem is that t.Rows.Count = 600000 and this loop works 9 hours. Any ideas how to make this faster?</p> <p>Regards kazik</p>
c#
[0]
2,686,397
2,686,398
C++ no match for operator<< Error
<p>I'm nearing the end of an intro class and I cannot for the life of me figure out what's going on here. First, the code:</p> <pre><code>#include &lt;iostream&gt; #include &lt;fstream&gt; using namespace std; int main( ) { double id = 0.0; double rate = 0.0; double hours = 0.0; double gross = 0.0; ifstream wData; wData.open("workers.txt", ios::in); if (wData.is_open()) { for (int count = 0; count &lt; 8; count = count + 1) { wData &lt;&lt; id &lt;&lt; rate &lt;&lt; hours; gross = rate * hours; cout &lt;&lt; "Employee ID: " &lt;&lt; id &lt;&lt; "Gross Pay: " &lt;&lt; gross &lt;&lt; endl; } wData.close(); } else { cout &lt;&lt; "The file could not be opened." &lt;&lt; endl; } system("pause"); return 0; } </code></pre> <p>Next, the error:</p> <pre><code>41 no match for 'operator&lt;&lt;' in 'wData &lt;&lt; id' </code></pre> <p>That would be in the bit <code>wData &lt;&lt; id &lt;&lt; rate &lt;&lt; hours;</code></p> <p>I've done some poking around (I really like to try to solve these on my own) but I can't pinpoint precisely what's going on. I feel like it might be something really obvious that I'm brainfarting on.</p>
c++
[6]
657,537
657,538
Active data copying
<p>Is this expression correct?</p> <pre><code>{ char a; char *temp; for(int j = 0; j &lt; len; j++) { strcpy(&amp;temp[j], (char*)a); } } </code></pre> <p>in this code <code>a</code> gets updated externally by the user input/key stroke. I want to copy all incoming/updated <code>a</code> to the <code>temp</code> as an entire string.</p>
c++
[6]
3,331,545
3,331,546
what is the best way to maintain a 3 level hierarchy?
<p>How can I maintain a 3 level hierarchy by using a gridview?</p>
asp.net
[9]
832,303
832,304
How to Calculate Percentage for Profile Compltance
<p>I have Create Many tables For User Registration Like Naukri... When i finished registration i have to show user the profile completance ,exactly like naukri way .how can i do it in asp.net?</p>
asp.net
[9]
6,006,474
6,006,475
Add name in the ordered list
<p>Goal:<br> Add the name (the name that has even number in the <code>arraylist</code>) in the ordered list.</p> <p>Problem:<br> How should I do it with jQuery's <code>each</code> syntax? you also need to take account to even number.</p> <p>The array list also can be increased in the future.</p> <hr> <pre><code>var arrayTask = new Array(); arrayTask[0] = "aaa"; arrayTask[1] = 10; arrayTask[2] = "bbb"; arrayTask[3] = 11; arrayTask[4] = "bbb"; arrayTask[5] = 12; arrayTask[6] = "ccc"; &lt;OL id="test"&gt; &lt;LI&gt; &lt;LI&gt; &lt;LI&gt; &lt;LI&gt; &lt;LI&gt; &lt;LI&gt; &lt;LI&gt; &lt;LI&gt; &lt;LI&gt; &lt;/OL&gt; </code></pre>
jquery
[5]
4,425,531
4,425,532
IntPtr vs ref C#
<p>i have to import unmanaged dll into my C# application, I want to know what is the diferent between IntPtr and ref, and what you recommnded me to use and why? Note that both ways are working to me. For example:</p> <pre><code>[DllImport("mydll.dll", CallingConvention=CallingConvention.Cdecl)] static extern Result Init(IntPtr versionInfo); [DllImport("mydll.dll", CallingConvention=CallingConvention.Cdecl)] public static extern Result Init(ref Version versionInfo); </code></pre>
c#
[0]
5,654,803
5,654,804
javascript dynamic prototype
<p>I want extend a new JS object while creation with other object passing a parameter. This code does not work, because I only can extend object without dynamic parameter.</p> <pre><code>otherObject = function(id1){ this.id = id1; }; otherObject.prototype.test =function(){ alert(this.id); }; testObject = function(id2) { this.id=id2; }; testObject.prototype = new otherObject("id2");/* id2 should be testObject this.id */ var a = new testObject("variable"); a.test(); </code></pre> <p>Any suggestion?</p>
javascript
[3]
4,857,462
4,857,463
User Events - eg Check Box
<p>Is there a way the CheckedChanged event (or any other C# event) to be declared as User event? The problem is that if the property Checked is changed by code the Event is called and this is a thing that I would not want (for example in MFC the events are user events as opposed to property events). I by pass it with boolean flags and this is a little bit awkward in 2011!</p>
c#
[0]
3,350,063
3,350,064
How can I choose if I want to append text or html to a div generically?
<p>I'm writing a javascript library and I need to use jquery's append method to add content to a div. I thought that append() treats <code>"straight strings"</code> as text and <code>$("&lt;div&gt;html objects&lt;/div&gt;")</code> as html but apparently if you use <code>append("&lt;p&gt;")</code> then you will get the string parsed into html which means that strings need to be encoded before being appended.</p> <p>I would like to use something which works like append but which makes distinctions between strings which are to be treated literally and strings which are to be parsed BASED ON THE PARAMETER. Since this is a library I wouldn't like to duplicate all my functions to make text() and html() versions of each.</p> <p>For example, I want to be able to add the string <code>"&lt;p&gt;xx&lt;/p&gt;"</code> without it being parsed to html but when I want to add the same string as html then I would pass <code>$("&lt;p&gt;xx&lt;/p&gt;")</code> as a parameter instead.</p> <p>edit: Basically I'm tired of seeing tutorials use append() to append text, because it does not append text, it appends html. I want to know if there is a method which distinguishes appending strings from appending html objects.</p>
jquery
[5]
1,115,359
1,115,360
null on json data
<p>I am trying to parse this json data from the url but i get NULL how do i fix this issue.</p> <pre><code>$source = file_get_contents('http://partners.socialvi.be/e414f702cf3db89a2fe58066bbab369d65b6a058/activities/available.json'); $json = json_decode($source); var_dump($json); </code></pre>
php
[2]
5,610,660
5,610,661
is there a dictionary i can download for java?
<p>is there a dictionary i can download for java? i want to have a program that takes a few random letters and sees if they can be rearanged into a real word by checking them against the dictionary </p>
java
[1]
2,858,246
2,858,247
Should I interfere the normal Python garbage collection process
<p>I have a large hierarchical data set in Python. After I am done with it, I need to get rid of it -- so I just do a <code>del</code> on the root node of the hierarchy.</p> <p>Would it be OK to manually do a <code>gc.collect()</code> -- is it a good practice to remove large data quickly or should I not do it and let Python do it's business?</p> <p>What are (if any) the correct patterns to use <code>gc</code> manually?</p>
python
[7]
628,661
628,662
fetching and updating data from web service
<p>Data can be fetched into an application through web service can it be possible to update data in web service from our application ..</p>
asp.net
[9]
4,925,213
4,925,214
developing a game in android
<p>Hi I am new to android. I have done sample application availabe at android website. Now i want to develop an arkanoid game. I googled to know from where should i start but dun get any thing relevant. Any help will be highly appreciated, any detail in breif about from where i should start or what things i have to use to develop this game</p>
android
[4]
3,608,816
3,608,817
Validate a path
<p>Is there any way of validating if a path can be correct in .net or do I need to write something myself?</p> <p>What I have is a string that is supposed to be a valid path such as:</p> <pre><code>\\server\shared\folder\file.ext c:\folder\file.ext .\folder\file.ext \folder\file.ext %appdata%\folder\file.ext </code></pre> <p>The path does not need to exist on the machine where this is run and the network does not need to be accessible, I'm only interested to see if the path could ever be valid.</p> <p>Was thinking about splitting the path into filename and path and then using the Path.GetInvalidPathChars() and Path.GetInvalidFileNameChars() arrays to check if the path contains invalid filenames which would at least be a start. But there may be better ideas?</p>
c#
[0]
2,638,736
2,638,737
Once I determine a var exist in PHP do I need to keep checking it in that page?
<p>I have a basic PHP question, take the code below for example, let's say I need to use this 10 times on a page, is there a better way to do it?</p> <ul> <li>I realize I could wrap it in a function and just keep calling that function but is there a better way then to keep on checking if the item is set and equals a a certain value. After finding this out the first time is there some other way of remembering the result from the first time instead of doing it 10 different times?</li> </ul> <p>Hope that makes sense.</p> <pre><code>&lt;?PHP if (isset($_SESSION['auto_id']) &amp;&amp; $_SESSION['auto_id'] == "1") { //do something } // do other code here that breaks these up if (isset($_SESSION['auto_id']) &amp;&amp; $_SESSION['auto_id'] == "1") { //do something else } // do other code here that breaks these up if (isset($_SESSION['auto_id']) &amp;&amp; $_SESSION['auto_id'] == "1") { //do something else } // do other code here that breaks these up if (isset($_SESSION['auto_id']) &amp;&amp; $_SESSION['auto_id'] == "1") { //do something else } ...ect </code></pre> <p>?></p>
php
[2]
5,864,800
5,864,801
Android How to Unmount the Sd Card through Program..?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/4632039/how-to-safely-remove-sd-card-programmatically-on-android">How to safely remove SD card programmatically on Android</a> </p> </blockquote> <p>Hi Everyone iam new to android and in my application i got one requirement. My app needs to Unmounting and mouningt the SD Card time to time so please help me is there any way to unmount the SD card Programatically and Mount back using program itself.?</p>
android
[4]
2,999,940
2,999,941
Add values from second array after array values?
<p>There are similar questions however none quite tackes the problem.</p> <pre><code>Array('1','2','3') Array('4','5','6') </code></pre> <p>Assuming they both have keys 0, 1, 2. Merging the two arrays doesn't allocate the second array values after the first's since it overwrites keys with the same name. Neither using an union array operator (+) works. And using array_push results in this:</p> <pre><code>Array('1','2','3',Array('4','5','6')) </code></pre> <p>How can the values from array2 be added after the ones from array1 maintaining their order?</p>
php
[2]
1,546,317
1,546,318
jQuery - combine statements
<p>Could i trouble someone to help me combine these statements...everytime i do i get a script error, but am unable to debug what is exactly wrong...</p> <pre><code>&lt;script type="text/javascript"&gt; $(function() { $('.slideshow').after('&lt;div id="mininav" class="mininav"&gt;').cycle({ fx: 'fade', speed: 'fast', timeout: 5500, pause: 1, pager: '#mininav', before: function() { if (window.console) console.log(this.src); } }); }); &lt;/script&gt; &lt;script type="text/javascript"&gt; $(function() { $('.slideshow').hover(function() { $('#mininav-pause').show(); }, function() { $('#mininav-pause').hide(); }); }); &lt;/script&gt; </code></pre>
jquery
[5]
2,025,781
2,025,782
Using Fragments in android
<p>I have created application that supports API 10+. I have two classes in tabs Lets say class1 and class2. both extends activity. Now I would like to create swipes for API 14+. Seems like I have to create Fragments to use swipes. Can't I reused my old classes that extends Activity parent class to create Fragments? Or I have to create new classes from scratch for swipes?</p>
android
[4]
5,263,313
5,263,314
How to read Unsigned integer from binary file?
<p>How to read "Unsigned 8/16/24/32/64-bit integer" from binary file ? ( big-endian byte order ) unpack ? any examples ?</p>
python
[7]
4,460,470
4,460,471
How to append a textbox to a table row with jQuery?
<p>How to append a textbox to a table row with jQuery?</p>
jquery
[5]
3,620,110
3,620,111
PHP: print '<meta http-equiv="refresh" content="0;url=' with URL parameters
<p>How do I create this string with URL parameters? What I want is something like:</p> <pre><code>print '&lt;meta http-equiv="refresh" content="0;url=http://domain.com?a=1&amp;b=2"&gt;'; </code></pre> <p>But that doesn't pass my second parameter correctly. I get a ")" instead of a b. What am I doing wrong?</p> <p>I've tried <code>&amp;amp;</code> instead of the ampersand, but that doesn't work either,</p>
php
[2]
940,953
940,954
EditText focusing Issue..!
<p>In my app, I am using the edit text(text box) which contains some text by default. The problem with the text box is that when the text box is focused the cursor appears at the starting of the string, It does not appear at the end of the string, This case is happening only in Nexus S device, I tried it in some other deices like Mile-Stone and nexus, for those devices the cursor appears at the end of the string then why only in Nexus S it shows like this?? Can we control the cursor position in text box??</p> <p>Thanks, Ram.</p>
android
[4]
5,699,038
5,699,039
how to make a Questionnaire iPhone app with sqlite
<p>I want to make an iPhone app just like a questionnaire/Quize, and want to store all questions in sqlite database , i need to have One question that can be a label and 4 radio buttons for answers, user will select the option and will go for the next question, questions and answers will be saved in sqlite and at the end user will come to know how many he made correct or wrong choices.</p> <p>Please suggest me any tutorial or anything that can be help full for me,please guise i will be grateful to u for this kindness in advance.</p>
iphone
[8]
2,570,555
2,570,556
how to play live streaming with mxplayer with rtmp url
<p>Hi I'm trying to make some live streams work with mxplayer but I'm confused can you guys help me how can I play a live sstreaming in mxplayer I have a app and I want to play it from there I got the rtmp URL but how can I play it ?</p>
android
[4]
5,744,722
5,744,723
how to combine 3 conditions by "OR" in jquery?
<p>Is there anyway to combine 3 conditions by "OR" in jquery? Eg, <code>$(t_obj).keyup(function(e) || $('#sendResp').click(function(e) || $('.emo').click(function(e) {</code> ? I have tested to combine them but I get error. How to combine them?</p>
jquery
[5]
214,948
214,949
Anything wrong with this code?
<p>I am using this to determine which view to go to next, from the result as input from UITableView. The following code isn't working, but I think it should be!</p> <p>Do you see anything wrong with it? </p> <pre><code>NSString *option = [menuArray objectAtIndex:indexPath.row]; if (option == @"New Transaction"){ NTItems *nTItemsController = [[NTItems alloc] initWithNibName:@"NTItems" bundle:nil]; [self.navigationController pushViewController:nTItemsController animated:YES]; [NTItems release]; } else if ([option isEqualToString:@"Previous Transactions"]){ } else if ([option isEqualToString:@"Reprint a reciept"]){ } else if ([option isEqualToString:@"Settings"]){ } else if ([option isEqualToString:@"Logout"]){ LoginViewController *nTItemsController = [[LoginViewController alloc] initWithNibName:@"LoginViewController" bundle:nil]; [self.navigationController pushViewController:nTItemsController animated:YES]; [nTIemsController release]; } </code></pre> <p>Each item/object is defined as follows:</p> <pre><code>[menuArray addObject:[NSDictionary dictionaryWithObjectsAndKeys: NSLocalizedString(@"Logout", @"Logout"), @"title", nil, nil]]; </code></pre>
iphone
[8]
3,700,997
3,700,998
Accessing method and parameter history with Java
<p>I'm currently working in a project in Liferay in which i'd like to be able to access my method and parameters these methods were given, in the history. This is done in case there is an exception being thrown in certain blocks of code.</p> <p>I've already searched and it is easy to get the method name history (Thread.currentThread().getStackTrace();) but i'd like to also know what parameters were given to these methods.</p> <p>For example:</p> <pre><code>public class A { public static void main(String[] Args) { try { System.out.println(new B().someMethod(5)); } catch (Exception e) { //GET HISTORY } } } public class B { public int someMethod(int i) throws Exception { i += 2; throw new Exception("Expected Exception to Generate History Search"); return i; } } </code></pre> <p>Is it possible to learn how can i, in class A, when I catch the exception, all that data? And of so, how do I do that?</p>
java
[1]
2,667,169
2,667,170
Android- openCV on Android
<p>Im trying to use the library on Android. But there was an error that I dont understand. Here is the description on my eclipse.</p> <p>Description Resource Path Location Type <em>*</em> Android NDK: Please correct error. Aborting . Stop. OpenCV Sample - color-blob-detection line 23, external location: C:\cygwin\android-ndk-r8e\build\core\build-shared-library.mk C/C++ Problem</p>
android
[4]
70,006
70,007
want to extract html and height & width of div
<p>my code is here which is not returning the result i want</p> <pre><code>var content = "&lt;div id='content_dv'&gt;"; content += "&lt;table border='1' style='height:auto;width:auto;'&gt;"; content += "&lt;tr&gt;"; content += "&lt;td&gt;"; content += "This is row 1"; content += "&lt;/td&gt;"; content += "&lt;/tr&gt;"; content += "&lt;tr&gt;"; content += "&lt;td&gt;"; content += "This is row 2"; content += "&lt;/td&gt;"; content += "&lt;/tr&gt;"; content += "&lt;tr&gt;"; content += "&lt;td&gt;"; content += "This is row 3"; content += "&lt;/td&gt;"; content += "&lt;/tr&gt;"; content += "&lt;/table&gt;"; content += "&lt;/div&gt;"; alert($(content).find('#content_dv').html()); alert("height "+$(content).find('#content_dv').height()); alert("width " + $(content).find('#content_dv').width()); </code></pre> <p>my content variable has some html and i want to show the data with in div id called "content_dv" and also i need to determine the height &amp; width of the div and height &amp; width of inner html of div.</p> <p>so please help me why my code is not working. what wrong in my code. thanks</p>
jquery
[5]
913,644
913,645
Adding number of days to a previous date inside incrementing variable for loop
<p>I am working on a function which adds a number of days to a date inside an incrementing variable loop. I am having a problem getting the date from the previous loop to add the next 30 days to that date. This seems to be working for the first 2 loops then breaks and I cannot figure out the correct code to get the previous dates.</p> <p>Here is my code:</p> <pre><code>$pay_cycles=5; $period=30; $arr = array(); for ($i=1;$i&lt;=$pay_cycles;$i++) { //if first loop get todays date if($i==1){ $due = date("Y-m-d"); //else add to previous date } else { $time = strtotime ( '+'.$period.' day' , strtotime ( $due-1 ) ) ; $due = date("Y-m-d", $time); } $arr[] = $due; } print_r($arr); </code></pre> <p>This is what prints</p> <pre><code>Array ( [0] =&gt; 2010-12-30 [1] =&gt; 2011-01-29 [2] =&gt; 2011-01-29 [3] =&gt; 2011-01-29 [4] =&gt; 2011-01-29 ) </code></pre> <p>Thanks for looking</p>
php
[2]
5,233,129
5,233,130
Unable to register on Google Play as a developer
<p>I am trying to register on android developer's console. But when I open the URL </p> <pre><code>https://play.google.com/apps/publish/signup?dev_acc=&lt;myaccno&gt; </code></pre> <p>The resulting page shows </p> <pre><code>404. That’s an error. The requested URL /about/developer-distribution-agreement.html was not found on this server. That’s all we know. </code></pre> <p>Infact the Google <a href="http://play.google.com/about/developer-distribution-agreement.html" rel="nofollow">Developer Distribution Agreement</a> is also not reachable.</p> <p>The checkbox below this message asks to accept the agreement but there is no agreement on the page.</p> <p>Is it a common problem ? </p>
android
[4]
1,622,277
1,622,278
submit() in Form Elements
<p>I noticed that you can call <code>submit()</code> in event handlers of form elements. For example, </p> <pre><code>&lt;input id="myInput" type="button" onclick="submit()" value="Test" /&gt; </code></pre> <p>clicking the button generated by the code above will submit the form. The funny thing is, I can't call <code>submit()</code> outside the event handler. There is no <code>submit</code> member defined for the input element.(<code>document.getElementById("myInput").submit</code> is <code>undefined</code>.) So, where is this function defined, and where can I find a reference to this function?</p>
javascript
[3]
5,789,317
5,789,318
passing a NULL as an argument in a function
<p>i created a book class which i having being working on as part of my assignment but its seems have being having one problem which i am failing to understand in my code below, this is my code</p> <pre><code>private: Book (string N = " ", int p = 100, string A = "", string P = "", string T = "", int Y = 2000) { cout &lt;&lt; "Book constructor start " &lt;&lt; N &lt;&lt; endl; Title=N; pages=p; Author=A; Publisher=P; Type=T; Yearpublished=Y; } ~Book(void) { cout &lt;&lt; "Book destructor start " &lt;&lt; Title &lt;&lt; endl; system("pause"); } public: static Book * MakeBook(string N = "", int p = 100, string A = "", string P = "",string T = "",int Y = 2000) { return new Book(N,p,A,P,T,Y); } static void DelBook(Book * X) { delete X; } </code></pre> <p>In the above code is a constructor and destructor, my question is what happens when I pass a <code>NULL</code> as an argument in the <code>stactic void DelBook</code> function? like this below</p> <pre><code>static void DelBook(NULL) { delete NULL; } </code></pre> <p>How can I make it compile if its possible to pass a NULL value? Thanks in advance.</p>
c++
[6]
4,258,177
4,258,178
Compiler Error: Invalid value in assignment when trying to change the origin of a UISwitch
<p>The following piece of code is giving me a compiler error: Invalid value in assignment, while changing the origin.</p> <p><code>CGPoint switchOrigin = CGPointMake(currentOrigin.x, currentOrigin.y + kTweenMargin); UISwitch *choiceSwitch = [UISwitch alloc]; **choiceSwitch.frame.origin = switchOrigin;**</code> </p> <p>But when I change it to the following it works properly. </p> <p><code>CGPoint switchOrigin = CGPointMake(currentOrigin.x, currentOrigin.y + kTweenMargin); UISwitch *choiceSwitch = [UISwitch alloc]; **CGRect switchFrame = choiceSwitch.frame; switchFrame.origin = switchOrigin;**</code> </p> <p>Can any one explain me the logic behind this.</p> <p>Thanks and Regards, Pranathi</p>
iphone
[8]
530,353
530,354
Replacing the contents of a TD based on certain conditions using jQuery
<p>I need to accomplish the following:</p> <p>I have a table that holds data that I need to edit/format: </p> <pre><code>&lt;tr&gt;&lt;td&gt;Tools and Other: Hammers&lt;/td&gt;&lt;tr&gt; &lt;tr&gt;&lt;td&gt;Tools and Other: Wrenches&lt;/td&gt;&lt;tr&gt; </code></pre> <p>Based on conditions, I need to change the contents to the following:</p> <pre><code>&lt;tr&gt;&lt;td&gt;Toolbox: Hammer&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;Toolkit: Wrench&lt;/td&gt;&lt;/tr&gt; </code></pre> <p>How would I <em>simply</em> change the contents of these two TDs dynamically using jQuery? Secondly - how would I remove just "Tools and Hammers" from every TD, if I decided to do it that way - like this:</p> <pre><code>&lt;tr&gt;&lt;td&gt;Hammers&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;Wrenches&lt;/td&gt;&lt;/tr&gt; </code></pre>
jquery
[5]
1,082,675
1,082,676
Play audio and video at a same time in iPhone application
<p>Is it possible to play audio and video file at a same time? I want to play different audio file and video file at a same time and also want control for both, so is it possible?</p>
iphone
[8]
5,838,776
5,838,777
Working with OLEDB ? In Asp.net?
<p>In we application, i am trying to access the excel sheet, when i am accessing .xls it is fine, but when i am using .xlsx then it is giving error like: </p> <pre><code> Microsoft.ACE.OLEDB.12.0' provider is not registered </code></pre> <p>Can you help me to solve this problem. </p>
asp.net
[9]
4,884,470
4,884,471
Delete confirmation issue on iPhone
<p>Hi <img src="http://i.stack.imgur.com/w2iC9.png" alt="enter image description here"></p> <p>I have added a light white/gray color to the background to see what happens when the "Delete Confirmation" is on. My problem is that when the delete button animates on screen, it does not reposition the content of my cell so I have this strange overlapping issue. Could anybody please help me? Do I have to make my own animation etc for this? Thank you.</p> <hr> <p>EDIT ADDED CODE: (I have removed the autoresizing because I don't get it to work..)</p> <pre><code>- (UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *LogCellId = @"LogCellId"; UITableViewCell *cell = [tv dequeueReusableCellWithIdentifier:LogCellId]; UILabel *lblSummary; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:LogCellId] autorelease]; lblSummary = [[[UILabel alloc] initWithFrame:CGRectMake(10.0, 10.0, 260.0, 30.0)] autorelease]; lblSummary.font = [UIFont fontWithName:@"Helvetica-Bold" size:13]; lblSummary.tag = SUMMARY_TAG; lblSummary.lineBreakMode = UILineBreakModeTailTruncation; lblSummary.opaque = YES; lblSummary.backgroundColor = [UIColor colorWithRed:240.0/255.0 green:240.0/255.0 blue:240.0/255.0 alpha:1.0]; [cell.contentView addSubview:lblSummary]; cell.contentView.backgroundColor = [UIColor colorWithRed:240.0/255.0 green:240.0/255.0 blue:240.0/255.0 alpha:1.0]; } else { lblSummary = (UILabel *)[cell viewWithTag:SUMMARY_TAG]; } lblSummary.text = [self.logList objectAtIndex:[indexPath row]]; return cell; } </code></pre>
iphone
[8]
4,462,635
4,462,636
jQuery - Combining elements
<p>I'm trying to combine the location of my WordPress theme folder to a jQuery element. I haven't used jQuery much before and I've done a little research but haven't found anything of value.</p> <p>Here's my JavaScript variable</p> <pre><code>&lt;script type="text/javascript"&gt;var templateDir = "&lt;?php bloginfo('template_directory') ?&gt;"; </code></pre> <p>And I'm wanting to add 'templateDir' to this:</p> <pre><code>$next = $('&lt;li&gt;&lt;a href="#" class="next" class="controls"&gt;&lt;img src="images/right_button.png" border="0" /&gt;&lt;/a&gt;&lt;/li&gt;'); </code></pre> <p>Ideally I thought it would be something like this, but it just errors.</p> <pre><code>$next = $('&lt;li&gt;&lt;a href="#" class="next" class="controls"&gt;&lt;img src="' + templateDir + 'images/right_button.png" border="0" /&gt;&lt;/a&gt;&lt;/li&gt;'); </code></pre> <p>So I'm not quite sure how it works. Thanks.</p> <p><strong>Update:</strong> Fixed the issue. Seems it was all down to the jQuery file not being first. Thanks.</p>
jquery
[5]
1,364,091
1,364,092
summing exponents in javascript
<pre><code>var total = 0; for (x = 1; x &lt; 16; x++) { var y = x + 1; var singleSum = Math.pow(x, y) + Math.pow(y, x); total = total + singleSum; document.write(total + "&lt;br&gt;"); } </code></pre> <p>I want to take <code>function(x,y) = x^y + y^x</code> where x starts at 1 and y starts at 2 then find the sum of the first 15 function calls. I can't figure out what I'm doing wrong. Any help would be appreciated. Thanks.</p>
javascript
[3]
2,985,042
2,985,043
Retain IEnumerable<T> value during postback
<p>I have an IEnumerable&lt; T> which is declared on the page like this:</p> <p>IEnumerable&lt; Person> person;</p> <p>When the page postsback, the person list is null. How can I retain the values of person list without declaring it as static? Sr. devs in my company say that you should not declare the list as static.</p>
asp.net
[9]
4,891,887
4,891,888
android connectivity check
<p>I am currently doing an android application that checks network availability(both wifi &amp; 3G). i have a code that perfectly working in activity . but i need it in broadcast receiver . i want to do some operations when the network is available . i have the permission </p> <p>plz help me.....</p> <p>The code is given below...</p> <pre><code> ConnectivityManager cm = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE); if ( cm.equals(ConnectivityManager.EXTRA_NO_CONNECTIVITY)) { Log.v("CONNECT", "CONNECTED"); } else { Log.v("CONNECT", "NOT CONNECTED"); } </code></pre> <p>`</p>
android
[4]
313,328
313,329
PHP imgefilter parameter value IMG_FILTER_SMOOTH question
<p>I was wondering what does the following sentence mean in laymens terms about the value of the IMG_FILTER_SMOOTH parameter value.</p> <p><code>At about 10, the picture is almost normal, because the original pixel values are given more weight than the combined sum of its neighbors.</code></p>
php
[2]
3,647,969
3,647,970
'System.Configuration.ConfigurationManager.AppSettings' is a 'property' but is used like a 'method'
<p>Configuration File</p> <pre><code>&lt;add key="ObjConn" value="Provider=SQLOLEDB;Persist Security Info=True;User ID=OMembers;PWD=OMembers;Initial Catalog=Omnex2007;Data Source=192.168.100.131"/&gt; </code></pre> <p>C# Code</p> <pre><code>strconnection = System.Configuration.ConfigurationManager.AppSettings("ObjConn"); sqlcon = new SqlConnection(strconnection); </code></pre>
asp.net
[9]
1,386,959
1,386,960
Iphone - UIImageView not showing up
<p>I have created a UIImageView in Interface Builder. When I run the application on the simulator the image shows up, when I run the application on the device the image doesn't show up. Any help is welcome. Thank you!!!</p>
iphone
[8]
4,829,400
4,829,401
Making the first row of UITableView hidden until user scrolls up on iPhone
<p>For the Facebook and a few other iPhone apps, I've seen what looks like a UITableView with the top row out of view while the other rows are rendered. Then when the user scrolls up, the the very first row becomes visible. Typically, the top most row is the "load more ..." item.</p> <p>Is there a trick to having the second row look like the first in the table?</p>
iphone
[8]
2,699,948
2,699,949
Slide an image by position using jquery
<p>I am trying to get the image to slide to its centre position on the respective li which is clicked. So for example if i click number 2 in the list it will slide to number 2. The issue is knowing where the user clicks next, how to figure the current position and which direction to slide.</p> <p>Here is my html</p> <pre><code>&lt;ul id="llist"&gt; &lt;li class="t current"&gt;&lt;a href="#"&gt;&lt;span&gt;solutions&lt;/span&gt;&lt;/a&gt;&lt;img src="images/bg-tab-leader-arrow.png" width="24" height="53" title="pointer" class="pointer" /&gt;&lt;/li&gt; &lt;li class="m"&gt;&lt;a href="#"&gt;&lt;span&gt;credit mangement solutions&lt;/span&gt;&lt;/a&gt;&lt;/li&gt; &lt;li class="b"&gt;&lt;a href="#"&gt;&lt;span&gt;third party additions&lt;/span&gt;&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; </code></pre> <p>Here is my jquery so far:</p> <pre><code>$('#leader #llist li').click(function() { $('.pointer').animate({'top':'+=61px'},1000,function() { $(this).removeClass('current'); }); }, function() { $('.pointer').animate({'top':'-=61px'},1000); $(this).addClass('current'); }); </code></pre> <p>Any help would be appreciated.</p>
jquery
[5]
3,861,407
3,861,408
Can't switch between 2 fragments
<p>I'm building application with actionbar.Tab with 4 fragments. I want to replace one of the list-fragments with other fragments by clicking on the first item of the listView inside that listFragment.</p> <p>The xml contains only image and the list view:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:id="@+id/joFl" android:layout_height="fill_parent" android:layout_gravity="center" android:gravity="center" android:orientation="vertical" &gt; &lt;ImageView android:id="@+id/imageView1" android:layout_width="match_parent" android:layout_height="wrap_content" android:src="@drawable/jo_logo" /&gt; &lt;ListView android:id="@android:id/list" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="center" android:background="@android:color/black" android:clickable="true" android:paddingTop="10dp" android:smoothScrollbar="true" &gt; &lt;/ListView&gt; &lt;/LinearLayout&gt; </code></pre> <p>and the code is:</p> <pre><code>{ case 0: { FragmentTransaction ft = getFragmentManager().beginTransaction(); ShultzFragment sf = new ShultzFragment(); ft.replace(R.id.joFl, sf); ft.commit(); break; } </code></pre> <p>I've also tried to change from LinearLayout to FrameLayout but it doesn't show the imageView and the replace() works but it show the 2 fragments together.</p> <p>Is there a simplier way to implement that? thanks in advance, udi</p>
android
[4]
3,570,461
3,570,462
Application crash due to ntdll.dll
<p>one of my C++ multi threaded Application crash due to ntdll.dll . my call stack looks as follows :- </p> <pre><code>#0 77452AB1 ntdll!RtlCopySid() (C:\Windows\system32\ntdll.dll:??) #1 00000000 0x777b3e14 in ??() (??:??) #2 00000000 0x00310000 in ??() (??:??) #3 00000000 0x00000000 in ??() (??:??) </code></pre> <p>crash behavior is unexpected sometime it crashes twice in a day and sometime it crashes after 4 or 5 working days . application runs 6 hours in a day. </p> <p>I am not able to solve this bug , is there anyone who came into such a scenario ??? </p>
c++
[6]
5,098,145
5,098,146
for loop breaking out for some reason after array comparison
<p>I have two arrays, and I'm comparing two values, and then setting a json object:</p> <pre><code>var compare = ["hh", "pictures", "videos", "aboutMe", "contactMe", "cat", "location"]; var data = ["pictures", "videos", "aboutMe", "contactMe", "cat", "location"]; for (var j=0; j&lt;compare.length; j++) { if (compare[j] === data[j]) { self.MenuItems.menu_item[j].added = "added"; }else if (compare[j] !== data[j]){ self.MenuItems.menu_item[j].added = ""; } } </code></pre> <p>for some reason, for all <code>self.MenuItems.menu_item[j]</code>, they all equal either "added" or "";...</p>
javascript
[3]
145,224
145,225
Size of text file
<p>I have a text file in sd card , I want to get size of text file in mb programatically from my android application. How can I get size of text file in MB programatically?</p>
android
[4]
2,481,350
2,481,351
Android twitter tweet with image
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/7609656/can-we-post-image-on-twitter-using-twitter-api-in-android">Can we post image on twitter using twitter API in Android?</a> </p> </blockquote> <p>I am working in an android application and I want to tweet a message and a picture to twitter. I am able to tweet only tweets to twitter by the code :</p> <pre><code>String token = prefs.getString(OAuth.OAUTH_TOKEN, ""); String secret = prefs.getString(OAuth.OAUTH_TOKEN_SECRET, ""); AccessToken a = new AccessToken(token, secret); Twitter twitter = new TwitterFactory().getInstance(); twitter.setOAuthConsumer(Constants.CONSUMER_KEY, Constants.CONSUMER_SECRET); twitter.setOAuthAccessToken(a); try { **twitter.updateStatus("New tweet");** twitter.//Which property of twitter should I use to tweet an image and //message } catch (TwitterException e) { // TODO Auto-generated catch block Log.e("Errorssssssssssssss", e.toString()); } </code></pre> <p>How do I include an image as well?</p>
android
[4]
5,082,664
5,082,665
Equivalent in C# of "Block values" in other languages
<p>In some languages, almost everything can be used as a value. For example, some languages let you treat a block of code as a unit which can return a value.</p> <p>In Scheme, a block of code wrapped in a <code>let</code> can return a value:</p> <pre><code>(define val (let () (define a 10) (define b 20) (define c (+ a b)) c)) </code></pre> <p>Perl 5 also supports blocks as values:</p> <pre><code>my $val = do { my $a = 100; my $b = 200; my $c = $a + $b; $c; }; </code></pre> <p>The closest approximation to block values I could come up with in C# was to use a lambda that is cast and immediately called:</p> <pre><code>var val = ((Func&lt;int&gt;)(() =&gt; { var a = 10; var b = 20; var c = a + b; return c; }))(); </code></pre> <p>That's not too bad and is in fact exactly what is happening semantically with Scheme; the <code>let</code> is transformed to a <code>lambda</code> which is applied. It's at this point that I wouldn't mind macros in C# to clean up the syntactic clutter.</p> <p>Is there an another way to get "block values" in C#?</p>
c#
[0]
789,561
789,562
Declaring a string globally in C#
<p>In the below rough sample code of C# I have to declared a string in condition and I am unable to access it out of that brace</p> <pre><code>if(//some condition) { string value1 = "something"; } //push to database value1 </code></pre> <p>In the above code compiler says <code>The name 'value1' does not exists in the current context</code> I need the <code>value1</code> to be declared in such a way that it must be accessed in whole page. I tried <code>protected value1</code> but that too didn't work. I hate to use it as a separate class. Is there anyway to declare globally?</p>
c#
[0]
2,522,797
2,522,798
How to define DO NOTHING in JavaScript
<p>I am displaying a confirm box in my app. When the user clicks on <code>Okay</code>, I close the window<br> when user clicks on <code>Cancel</code>, I want to do nothing but stay on the same page. </p> <p>What should I write in place of DO_NOTHING?</p> <pre><code> &lt;a href="#" onclick="confirm('Do you wan to close the application ?')?window.close():DO_NOTHING')"&gt;Close the application ?&lt;/a&gt; </code></pre> <p>If I keep it empty it does not work. If I write any random string it works but displays <code>string undefined</code> error.</p>
javascript
[3]
1,572,117
1,572,118
jquery .selectable checkboxes on change event
<p>im new here and i have a problem. i have a table of checkboxes 30x24. witch can be selected with a jquery widget selectable. but wen i use this widget on click event doesnt work anymore. </p> <p>this is my code:</p> <pre><code> $(function () { $("#selectable").selectable({ filter:'label', stop: function (){ $(".ui-selected input", this).each(function() { this.checked= !this.checked }); } }); }); function showUser(str,id) { if (str=="") { document.getElementById("txtHint").innerHTML=""; return; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 &amp;&amp; xmlhttp.status==200) { document.getElementById("txtHint").innerHTML=xmlhttp.responseText; } } var cb = $("#" + id); if (cb.is(':checked')) { fruits.push(str) } else{ fruits.splice(fruits.indexOf(str), 1); } xmlhttp.open("GET","ajax.php?q="+fruits+"&amp;c="+cost,true); xmlhttp.send(); } print " &lt;td bgcolor=#c1c1c1 &gt;&lt;label&gt; &lt;input name='"; print "checks"; print "' type='checkbox' id='"; print $id; print "' onchange='showUser(this.value,this.id)' value='"; print $leto . "." . $mesec . "." . $dan . ":" . $ura; print "' &gt; &lt;/label&gt;&lt;/td&gt;"; </code></pre>
jquery
[5]
2,388,757
2,388,758
Creation of a map from another map in Java
<p>I have to convert a Map- Map1 into Map2.</p> <p>Map1:</p> <pre><code>A.B.Key = "Key" A.B.Value = "Value" A.B.Key1 = "Key1" A.B.Value1 = "Value1" A.B.Key2 = "Key2" A.B.Value2 = "Value2" </code></pre> <p>Map2:</p> <pre><code>Key = Value Key1 = Value1 Key2 = Value2 </code></pre> <p>Map1 is created from this XML file:</p> <p>XML File:</p> <pre><code>&lt;A&gt; &lt;B&gt; &lt;Key&gt; Key &lt;/Key&gt; &lt;Value&gt; Value &lt;/Value&gt; &lt;/B&gt; &lt;B&gt; &lt;Key&gt; Key1 &lt;/Key&gt; &lt;Value&gt; Value1 &lt;/Value&gt; &lt;/B&gt; &lt;B&gt; &lt;Key&gt; Key2 &lt;/Key&gt; &lt;Value&gt; Value2 &lt;/Value2&gt; &lt;/B&gt; &lt;/A&gt; </code></pre> <p>I am getting the problem because Map1 contents are not in the order, in which Its mentioned in the XML file. Map1 is something like this:</p> <p>Actual Map1:</p> <pre><code>A.B.Key2 = "Key2" A.B.Key = "Key" A.B.Value = "Value" A.B.Value1 = "Value1" A.B.Value3 = "Value2" A.B.Key1 = "Key1" </code></pre> <p>Where am I going wrong?</p>
java
[1]
1,551,323
1,551,324
generics in java : identify Type of T
<p>I am writing some generic <code>DAO</code> as follows</p> <pre><code>public class MyGenericDAO&lt;T&gt; { Class&lt;T&gt; clazz; public void doSome(){ for(int =0 ;i&lt;14;i++){ //do something } } } </code></pre> <p>Now i want to initialize clazz based on Type of T? .How can i do it?</p> <p>For example if someone does <code>MyGenericDAO&lt;Xyz&gt; = new MyGenericDAO&lt;MyGenericDAO&gt;()</code> then type of <code>T</code> should be <code>Xyz</code>.</p> <p>How can i do it?Is it possible without refelection?</p>
java
[1]
3,211,541
3,211,542
Can a class return a static instance of itself? (in c#)
<p>Right now my class is set up as:</p> <p><code>enum Unit{Inches,Centimeters};</code></p> <p>Later on I have a step that sets all of the properties of each of these units into my classes instance variables. For example:</p> <pre><code>int unitBase; //10 for metric, 16 for american int label; switch(unit) { case Unit.Inches: unitBase = 16; unitLabel = "\"";break; case Unit.Centimeters: unitBase = 10; unitLabel = "cm";break; } </code></pre> <p>I would rather store this all in a Unit class or struct. Then, I would like to be able to access it in the same way you access colors, for example. You say <code>Color.Blue</code> for a blue color, I would like to say <code>Unit.Inches</code> for inches... That is why I dont make a unit base class and simply extend it.</p> <p>I know that there is a way to do this! Could anyone enlighten me?</p> <p>Thanks!</p>
c#
[0]
1,107,957
1,107,958
Packaging "visual studio c# windows application"project then setup on client without need to install Netframework
<p>I finished programming my project with Visual studio 2008 c# windows form application and I created setup project using plug-in (setup wizard) with visual studio 2008. but when I install my program after packaging with this plug-in there is wrong message appear on the screen:"this install want to install .Netframework 3.5" what I want..? I want packaging my project to instal on client computer without need to install .Netframework liprary.How I can do it using any program anyway...please give me express steps</p> <p>I not mean:I never want to install .Netframework 3.5 but I want to know waht is the way to summary wahat the liprary in using with my project then include this liprary in my project package, becasue I want to small my setup file size.</p> <p>sorry because my question wasn't purposely.</p> <p>Thank you all..</p>
c#
[0]
4,518,411
4,518,412
jQuery animate height in different class
<p>Is it possible to have height of animate in different class as is in my case ".bar1"???</p> <p><code>$('.bar1').animate({'height':'58%'},1000);</code></p> <p>Just to get idea what I mean: <strong>'.bar_graf'</strong></p> <p><code>$('.bar1').animate({'.bar_graf'.'height':'58%'},1000);</code></p>
jquery
[5]
1,892,095
1,892,096
custom super global in PHP
<p>Is it possible to define a custom super global variable? (whether in code, or using php.ini)</p> <p>Example, for all projects I use a custom framework. The framework essentially stores all data about running instance of the script (template loaded, template variables, etc.) in a single variable. I'd like that variable to become cross-system accessible.</p> <p>I am perfectly aware of <code>$_GLOBALS</code> and <code>global</code>, however the question is asking if it is possible to define custom super global variable, e.g. $foo, which would become accessible by the same name in any scop.</p>
php
[2]
2,376,594
2,376,595
Email parsing: TypeError: parse() takes at least 2 arguments (2 given)
<p>I am getting the following error while calling a built-in function to parse an email in Python.</p> <pre><code>txt = parser.Parser.parse(fd, headersonly=False) </code></pre> <p>And the error i got is </p> <pre><code>TypeError: parse() takes at least 2 arguments (2 given). </code></pre> <p>Can anybody tell me the way to solve this problem?</p>
python
[7]
4,551,255
4,551,256
Handle events of objective c/c++ for the iphone devlopment using xcode 3.2
<p>I am working as a developer for the iPhone applications, but i m stuck at certain point, can anyone tell me that how do i handle the events of C or C++ in Xcode 3.2 for the iPhone development?</p>
iphone
[8]
790,302
790,303
Change a Specific Color in an ImageIcon
<p>I am working with 24x24 pixel icons. And I would like to be able to change a specific color within this icon to a different color. For example turn the white areas to red.</p>
java
[1]
440,647
440,648
request sql of search in database sqlite
<p>I have an edit text where the user write the name I want the syntax of request "select name from table where name begin of the contain of the edit text"</p>
android
[4]
5,947,120
5,947,121
Pointers assignment
<p>What is the meaning of </p> <pre><code>*(int *)0 = 0; </code></pre> <p>It does compile successfully</p>
c++
[6]
3,929,662
3,929,663
Using structs in C# to read data
<p>Say I have a struct defined as such</p> <pre><code>struct Student { int age; int height; char[] name[12]; } </code></pre> <p>When I'm reading a binary file, it looks something like</p> <pre><code>List&lt;Student&gt; students = new List&lt;Student&gt;(); Student someStudent; int num_students = myFile.readUInt32(); for (int i = 0; i &lt; num_students; i++) { // read a student struct } </code></pre> <p>How can I write my struct so that I just need to say something along the lines of</p> <pre><code>someStudent = new Student(); </code></pre> <p>So that it will read the file in the order that the struct is defined, and allow me to get the values as needed with syntax like</p> <pre><code>someStudent.age; </code></pre> <p>I could define the Student as a class and have the constructor read data and populate them, but it wouldn't have any methods beyond getters/setters so I thought a struct would be more appropriate.</p> <p>Or does it not matter whether I use a class or struct? I've seen others write C code using structs to read in blocks of data and figured it was a "good" way to do it.</p>
c#
[0]
5,225,183
5,225,184
Finding free non-intersecting rectangle shaped areas between rectangles in C#
<p>I have a following problem. A large rectangle contains smaller non-intersecting rectangles (The black rectangles in the picture below) and I need to find an algorithm to fill remaining free area with non-intersecting rectangles(red ones in the picture below). Speed is not an issue for the algorithm. Also if someone would have an example source code of the algorithm I would really appreciate that.</p> <p>Edit. Small clarification I need to get the coordinates of the red rectangles not to draw them. I am also working with point data not images.</p> <p><img src="http://koti.mbnet.fi/niempi2/Squares.gif"></p>
c#
[0]
2,922,902
2,922,903
How to strtotime date format like this
<p>I would like to strtotime dateformat like this - Fri Jun 15 05:38:11 +1000 2012 How could I do that? Basically I need to strtotime it, then do the following - <code>$ago = time()-strtotime(Fri Jun 15 05:38:11 +1000 2012);</code> and then do this - </p> <pre><code>$ago = $ago / (60*60*24); echo $ago.' days ago'; </code></pre> <p>So I need one thing - strtotime(Fri Jun 15 05:38:11 +1000 2012) which will work as it need to work.</p> <p>If this type of date cannot be strtotime, then how can I edit it, so it could be strtotime?</p>
php
[2]
4,291,893
4,291,894
An automated algorithm tool for running time
<p>I am wondering if there is an open source project that can run the algorithm and tell us what the running time is (just need to know the Big-Oh running time). </p> <p>I know I can do this with hands, but a lot of algorithms are too long or too complex to actually trace the running time.</p> <p>Thanks.</p> <p>PS: Mainly for C++ (but it works for more than just C++ would be nice!!)</p>
c++
[6]
75,414
75,415
PHP Write and Read from Text File
<p>I have an issue with writing and reading to text file.</p> <p>I have to first write from a text file to another text file some values which I need to read again. Below are the code snippets:</p> <p>Write to text file:</p> <pre><code>$fp = @fopen ("text1.txt", "r"); $fh = @fopen("text2.txt", 'a+'); if ($fp) { //for each line in file while(!feof($fp)) { //push lines into array $thisline = fgets($fp); $thisline1 = trim($thisline); $stringData = $thisline1. "\r\n"; fwrite($fh, $stringData); fwrite($fh, "test"); } } fclose($fp); fclose($fh); </code></pre> <p>Read from the written textfile</p> <pre><code>$page = join("",file("text2.txt")); $kw = explode("\n", $page); for($i=0;$i&lt;count($kw);$i++){ echo rtrim($kw[$i]); } </code></pre> <p>But, if I am not mistaken due to the "/r/n" I used to insert the newline, when I am reading back, there are issues and I need to pass the read values from only the even lines to a function to perform other operations.</p> <p>How do I resolve this issue? Basically, I need to write certain values to a textfile and then read only the values from the even lines.</p> <p>Thanks In Advance</p>
php
[2]
1,288,682
1,288,683
How to send ">' string in a java code to server
<p>When i try to send a value "Login>Success" to server i get the value as Login%3ESuccess. How can i send the greater than symbol in the java string.</p>
java
[1]
1,015,073
1,015,074
Detect if a string is a link w/jQuery
<p>I need to be able to detect if a target string is a link or not. If yes, i need to grab the URL and place it into a var, do something with the string a (run through a plugin to truncate), and then wrap new string into the link again. I think i should be able to accomplish this with jQuery, right?</p> <pre><code>&lt;div class="item"&gt;some string&lt;/div&gt; &lt;div class="item"&gt;another string&lt;/div&gt; &lt;div class="item"&gt;&lt;a href="myUrl.php"&gt;linked string&lt;/a&gt;&lt;/div&gt; </code></pre>
jquery
[5]
3,585,734
3,585,735
Create Parent Thread in java
<p>Often I create Child threads within the main() as </p> <pre><code>Thread thread = new Thread(new Runnable(){public void run(){}}); </code></pre> <p>Likewise, is it also possible to create parent threads ?</p>
java
[1]
176,872
176,873
Simulate a 'Home Button' click
<p>After reading that <a href="http://stackoverflow.com/questions/355168/proper-way-to-exit-iphone-application">there is no proper way to exit an iPhone app</a>, is there a way to programmatically send a Home button click on the device, that would minimise the app?</p> <p>"Apple developers don't do this." is an acceptable answer :)</p> <p>Thanks</p>
iphone
[8]
4,695,296
4,695,297
Error on some device but run on emulator
<p>My app can run perfect on emulator and some device but another device can not run, i tested my app on HTC Wildfire S ,samsung S2, sony Arc and they can run but some phone like sony xperia play, arc S can not run ( they can install my app but get error force close when run inside . Im so sorry for my english is not good, anyone get error like my problem can tell me.</p>
android
[4]