Unnamed: 0
int64
65
6.03M
Id
int64
66
6.03M
Title
stringlengths
10
191
input
stringlengths
23
4.18k
output
stringclasses
10 values
Tag_Number
stringclasses
10 values
3,899,208
3,899,209
textview get overide by image from gallery
<p>I am trying to place text view on image view of particular size, but when i load the image from photo gallery my text view get over written and I am not able to write upon it . I guess, when I create a rectangle frame for bi then image from gallery get override to text view. what should I do?</p> <p>answer: this is working ocde:</p> <pre> - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { // set image emailImage1 = [info objectForKey:UIImagePickerControllerOriginalImage]; //bi.image = [info objectForKey:UIImagePickerControllerOriginalImage]; image = [info objectForKey:UIImagePickerControllerOriginalImage]; bi = [[UIImageView alloc ] initWithImage: image ]; bi.frame = CGRectMake(20.0f, 100.0f,260.0f, 285.0f); [self.view addSubview: bi]; [self.view bringSubviewToFront:scroll]; [[picker parentViewController] dismissModalViewControllerAnimated:YES]; [picker release]; } - (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker { // release picker [[picker parentViewController] dismissModalViewControllerAnimated:YES]; [picker release]; } </pre> <p>help plz</p>
iphone
[8]
5,420,219
5,420,220
Auto-generate class hierarchy and code structure in Eclipse
<p>How can I auto-generate class hierarchy diagrams and documentation from function/class headers in eclipse.</p>
java
[1]
2,672,579
2,672,580
checking if ace exists and if points >21
<p>In my blackjack program i have:</p> <pre><code>Card c = dealCard(deck); //deals the card updatePoints(players[i], c); // calls updatePoints below. </code></pre> <p>The updatePoints function looks like this:</p> <pre><code>public static void updatePoints(Player player, Card c){ int point = c.getValue(); if(player.getPoints() + point &gt;21 &amp;&amp; (player.ace1 == 11 || player.ace2 == 11 || player.ace3 == 11 || player.ace4 == 11)){ player.points -= 10; player.setPoints(point); if (player.ace1 == 11){ player.ace1 = 1; }else if(player.ace2 == 11){ player.ace2 = 1; }else if(player.ace3 == 11){ player.ace3 = 1; }else if (player.ace4 == 11){ player.ace4 = 1; } } if (point == 1){ //default value for player.ace1 .. player.ace4 is 0 if(player.ace1 == 0){ player.ace1 = 11; player.setPoints(11); }else if (player.ace2 == 0){ player.ace2 = 11; player.setPoints(11); }else if (player.ace3 == 0){ player.ace3 = 11; player.setPoints(11); }else if(player.ace4 == 0){ player.ace4 = 11; player.setPoints(11); } }else{ player.setPoints(point); } return; } </code></pre> <p>for some reason when the points go over 21 this doesnt change the ace value and doesnt adjust the ace. any help will be appreciated. Thank you</p>
java
[1]
5,203,644
5,203,645
Connecting ASP.net with Access 2007
<p>Hi im a beginner and i want to know how to connect asp.net with access 2007. i need to add, update and delete data in a data grid. can you please help me out? im new and i need full instructions to do it. its really urgent... can you please provide me the complete steps to do this?</p>
asp.net
[9]
407,022
407,023
passing filename as arguments in c++
<p>I have to pass four different text files in an argument in c++ program. How do i pass??</p>
c++
[6]
611,033
611,034
How I can join compiled jasper file and my project in java?
<p>I have design my project in iReport and I have compiled successfully. Now I want to add the compiled jasper file to add in my java project. May any one help me?</p>
java
[1]
2,954,933
2,954,934
set the size of the tooltip dialog box depending on the text
<p>How do i set the size of the tooltip dialog box. the tooltip text must be displayed in one line rather than wrapping the text to other line.</p> <p>in firefox and IE7 tooltip text is showed in one line but in IE8 the tooltip text is wrapped . i.e text is displayed in 2 lines.</p> <p>asp:Image runat="server" ID="iUrl" Visible="false" ImageUrl="~/Widgets/FMP_Printers/images/status icons/icon_Fault_Enabled.gif" /></p> <pre><code> if (txtUrl.Text.ToUpper().IndexOf("HTTP://") &lt; 0 &amp;&amp; txtUrl.Text.ToUpper().IndexOf("HTTPS://") &lt; 0) { iUrl.Visible = true; iUrl.ToolTip = "ghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghgh"; valid = false; } </code></pre>
asp.net
[9]
3,892,986
3,892,987
Finding Controls In A Data-Bound Template
<p>I'd like to find out if a certain type of control exists on a page. It's easy enough to iterate through the Controls collection recursively but I'd also like to check on first load whether the control exists in any of the templates (ContentTemplate, EditItemTemplate, ItemTemplate, SelectedItemTemplate etc) contained in a control as well. Does anyone know if its possible, and if so how? There doesn't appear to be a Templates collection per se and it isn't obvious how to query an ITemplate for its contents.</p> <p>Thanks in advance.</p>
asp.net
[9]
169,312
169,313
Javascript variables inherited by functions
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/5555464/javascript-closure-of-loop">Javascript: closure of loop?</a> </p> </blockquote> <p>Pseudo javascript:</p> <pre><code>for (i, i&lt;10, i++) { new element.addEvent('click', function(){ alert(i) }).inject(dom) } </code></pre> <p>When the loop finishes all the onclick events will trigger alerts with the 'final' value of i. What is the 'correct' way of having them alert the value of i as it was when the onclick event was added?</p> <p>When I say correct I mean that I'm aware there are several ways of achiving this behavior, but I want to know the standard (ie expected by people that may encounter the code) way. Thanks.</p>
javascript
[3]
2,751,304
2,751,305
Android: odd behaviour on Galaxy Nexus S device, v 2.3.6
<p>So a bit of background: this device has a ton of apps and services running simultaneously. On this particular app I'm developing, sometimes odd things happen. Like I try creating a "game card" and select an image for the card from the gallery. Sometimes, when the image is pasted, the other attributes of the card go away. Also, sometimes, the card gets saved twice when I press the save button. Other times, everything works fine.</p> <p>On every other device I've tested my app, there is no such problem. What do you think is the issue? Personally, I feel that it could be a memory related. Thanks!</p>
android
[4]
1,582,848
1,582,849
Zoom some portion of UIImage to fill the entire screen iPhone
<p>What I want to do is to zoom some portion of the image into the entire screen.</p> <p>To accomplish that I have a UIImage on UIImageView, which in turn is a subview of UIScrollView. However if I use zoomToRect and specify the rect of the image portion I want to zoom, the portion is zoomed until one of its bounds reached the screen bounds and does not fill the entire screen. </p> <p>Can someone suggest how can I accomplish what I want?</p>
iphone
[8]
2,450,237
2,450,238
jquery when click on link, move position to textarea
<p>Whenever you press comment on facebook, u can see the page move to textarea in comment box.</p> <p>how do i achieve that? focus? any example?</p>
jquery
[5]
4,980,232
4,980,233
android - overriding the back button
<p>I have a <code>webView</code> inside an Activity's layout. If back button is pressed, I want that view to disappear and other views to become visible, to I did the following:</p> <pre><code> @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK &amp;&amp; web.getVisibility()==View.VISIBLE) { restoreInitalState(); // set Visibility of Views APP_CONSTANTS.LOGIN_OP_CANCELLED(getApplicationContext()); // inform the user that the current operation was cancelled } return super.onKeyDown(keyCode, event); } </code></pre> <p>it works BUT it finishes the Activity immediately after calling my methods, like if the back button was pressed 2 times. I need to keep the current Activity and just call my methods mentioned above. Any suggestions?</p>
android
[4]
3,655,029
3,655,030
How to change the text of an alert message with JQuery icon
<p>I like to change the text of an alert message with JQuery. My code looks like:</p> <pre><code>&lt;p&gt;&lt;span id="tips" class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"&gt;&lt;/span&gt;&lt;/p&gt; var tips = translate("Verwijder") + " " + $('#oms' + uploadId).text() + "?"; $('#tips').text(tips); </code></pre> <p>For some reason this does not work. Can anyone please help?</p>
jquery
[5]
5,967,500
5,967,501
Android:notification problem
<p>I have an application that will clear the missed calls displayed on the status bar. I can clear it but when you restart the phone, the missed calls on the status bar is still there? How can I permanently remove it using my app?</p>
android
[4]
1,666,231
1,666,232
AlertDialog.Builder is undefined
<p>Thought I had it working but I get another error! I'm still new to Android and can't seem to fix this issue no matter what. I know it's to do with using "new Builder(this);". However I don't know what else to use, any help would be appreciated!</p> <pre><code>changeDay.setOnClickListener(new OnClickListener(){ public void onClick(View v){ AlertDialog.Builder b = new Builder(this); b.setTitle("Select Day"); String[] types = {"1", "2", "3"}; b.setItems(types, new DialogInterface.OnClickListener(){ public void onClick(DialogInterface dialog, int which){ dialog.dismiss(); switch(which){ case 0: day = "1"; break; case 1: day = "2"; break; } } }); } }); </code></pre>
android
[4]
3,004,097
3,004,098
how to make a separated copy of an ArrayList
<blockquote> <p><strong>Possible Duplicate:</strong><br /> <a href="http://stackoverflow.com/questions/715650/java-how-to-clone-arraylist-but-also-clone-its-items">Java: how to clone ArrayList but also clone its items?</a> </p> </blockquote> <p>I have a sample program like the following:</p> <p>ArrayList orginalInvoice = new ArrayList();</p> <p>//add some items into it here</p> <p>ArrayList copiedInvoice = new ArrayList();</p> <p>copiedInvoice.addAll(orginalInvoice);</p> <p>I thought I can modify items inside the copiedInvoice and it will not affect these itmes inside originalInoice. But I am wrong. </p> <p>How can I make a separated copy of an ArrayList? clone? thanks,</p>
java
[1]
2,980,515
2,980,516
AttributeError: 'DateTemplates' object has no attribute '_to_date'
<p>The code posted <a href="https://github.com/ceradon/cerabot-rewrite/blob/master/cerabot/tasks/date_templates.py" rel="nofollow">here</a>, I tried to compile the program but everytime I do it goves me this traceback:</p> <pre> Traceback (most recent call last): File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main "__main__", fname, loader, pkg_name) File "/usr/lib/python2.7/runpy.py", line 72, in _run_code exec code in run_globals File "/home/ceradon/cerabot-rewrite/cerabot/tasks/date_templates.py", line 187, in bot = DateTemplates() File "/home/ceradon/cerabot-rewrite/cerabot/tasks/date_templates.py", line 19, in __init__ super(DateTemplates, self).__init__() File "cerabot/bot.py", line 51, in __init__ self.setup() File "/home/ceradon/cerabot-rewrite/cerabot/tasks/date_templates.py", line 110, in setup self._load_templates() File "/home/ceradon/cerabot-rewrite/cerabot/tasks/date_templates.py", line 61, in _load_templates self._to_date.append(template.get(1).value.lower()) AttributeError: 'DateTemplates' object has no attribute '_to_date' </pre> <p>I'm lost, can anybody help in figuring this out?</p>
python
[7]
3,254,439
3,254,440
Understanding re.search in Python
<p>I am trying to allow users to Enter alphanumerics,underscores and spaces for a name. I've been using <code>if not re.search(r'^[\w-]+$', name):</code> to check if the name has anything other than alphanumerics,underscores and spaces. But here I can just enter one word, not multiple. What am I doing wrong?</p>
python
[7]
4,857,510
4,857,511
How do I plot a STOCK historical graph in android app?
<p>I wanted to plot a stock historical graph based on google finance in my android app . The problem is I can't find the api for just the stock chart alone and I must try to find another ways to do it.</p> <p>I thought of a way but don't know what whether it works</p> <p>the steps are as follows.. 1) get the details from csv file 2) read the csv file 3) plot the graph using the information of the csv file.(WHICH I DON'T KNOW HOW TO DO IT)!</p> <p>so if my steps above works , I would only want to know how to plot the graph.</p>
android
[4]
2,541,093
2,541,094
Development on sony xperia neo v
<p>I started android development.I have always made ​​use of emulators and eclipse. Because I'm doing more and more developing, I consider a device to buy.</p> <p>I already have tested applications on the HTC Desire and google nexus s.</p> <p>I want to buy a <code>sony ericson xperio neo v</code>, but do not know if this is the same? </p> <p><code>Problem: Is development for all devices with android the same?</code></p>
android
[4]
530,386
530,387
raising exceptions issue
<p>here is my code:</p> <pre><code>class longInputException(Exception): def __init__(self, length, max): Exception.__init__(self) self.length = len(length) self.max = max try: max = 3 s = raw_input('Enter something--&gt;') if len(s) &gt; max: raise longInputException(s, max) except longInputException, x: print 'longInputException: the input was of length %d, \ was expecting less than or equal to %d' % (x.length, x.max) else: print 'No exception was raised.' </code></pre> <p>What I don't understand is why <code>x</code> is used in the <code>longInputException</code>'s <code>except</code> statement. why not just used <code>self</code> in the substitution tuple?</p>
python
[7]
5,848,209
5,848,210
Get Selected HTML in browser via Javascript
<p>I have a requirement for my web app to allow the user to "Print Selected Only". In other words, a user selects text and potentially images and then clicks this option. I've seen examples of getting selected text with Javascript, but haven't found a solution for getting the selected html itself. </p> <p>As an example if I have a document like so:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;/head&gt; &lt;body&gt; &lt;p&gt;A bunch of text&lt;/p&gt; &lt;img src="someimage.jpg" /&gt; &lt;p&gt;Even more text&lt;/p&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>If user highlights the image and the second paragraph, I'd want the javascript to return:</p> <pre><code>&lt;img src="someimage.jpg" /&gt; &lt;p&gt;Even more text&lt;/p&gt; </code></pre> <p>Is this possible and how would one go about doing it?</p> <p>Edit: I ended up going with a js library called <a href="http://code.google.com/p/rangy/" rel="nofollow">Rangy</a> for this.</p>
javascript
[3]
3,579,794
3,579,795
Language split to minimize .apk file
<p>I'm creating an app with 3 different languages. Every language contains a separate audio file (8 mb each). Is it possible to split/export the project to 3 different .apk files prior to release on Market? I really do not want to put everything in one .apk due to the 24+ mb file size.</p>
android
[4]
5,646,989
5,646,990
How to display previous day and next day dates in html using Javascript
<p>I am working on some simple Javascript to display the current date with previous and next date links.</p> <p>my code snippet as follows</p> <pre><code>&lt;script type="text/javascript"&gt; var currentTime = new Date(); var month = currentTime.getMonth()+1; var day = currentTime.getDate(); var year = currentTime.getFullYear(); var date = month + " " + day + " " + year; function ShowSchedule() { document.getElementById("today").innerHTML = date; } function ShowDay(isNextDay) { if(isNextDay) { var nextDay = new Date(year, month, day+1); date = nextDay.getMonth() + " " + nextDay.getDate() + " " + nextDay.getFullYear(); ShowSchedule(); } else{ var prevDay = new Date(year, month, day -1); date= prevDay.getMonth() + " " + prevDay.getDate() + " " + prevDay.getFullYear(); ShowSchedule(); } } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;table border="1"&gt; &lt;tr&gt; &lt;th&gt; &lt;a id = "prev" href="#" onClick="ShowDay(false)"&gt;Prev&lt;/a&gt; &lt;/th&gt; &lt;th id="today"&gt; &lt;/th&gt; &lt;th&gt; &lt;a id = "next" href="#" onClick="ShowDay(true)"&gt;Next&lt;/a&gt; &lt;/th&gt; &lt;/tr&gt; &lt;/table&gt; &lt;script&gt;ShowSchedule();&lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>The above code working for current, previous and next date also, but the problam is if i click on next day link it will get increase for only one day, same thing for previous link also. My requirement is i can able to whatever date i want by clicking previous and next link navigations.</p> <p>Any help will be appreciated.</p>
javascript
[3]
5,135,291
5,135,292
onPrepareOptionsMenu android app
<p>I am trying to use the onPrepareOptionsMenu and when I press the menu, it does nothing!! Where am I going wrong?</p> <p>Also, am I using the finish (); command right? When the user presses exit(menuX) I want them to exit the application completely, not the activity.</p> <p>Thanks! :)</p> <pre><code>public boolean onCreateOptionsMenu(Menu menu){ super.onCreateOptionsMenu(menu); MenuInflater getItnow = getMenuInflater(); getItnow.inflate(R.menu.main_menu, menu); return true; } public boolean onPrepareOptionsMenu(MenuItem item){ switch (item.getItemId()){ case R.id.menuA: startActivity(new Intent("com.abc.example.A")); return true; case R.id.menuB: startActivity(new Intent("com.abc.example.B")); return true; case R.id.menuC: startActivity(new Intent("com.abc.example.C")); return true; case R.id.menuD: startActivity(new Intent("com.abc.example.D")); case R.id.menuX: finish(); } return false; } } </code></pre>
android
[4]
3,684,769
3,684,770
dir() function in commandline vs IDLE
<p>I've tried running the following code in IDLE:</p> <pre><code>import sys dir(sys) </code></pre> <p>There is no result:</p> <pre><code>&gt;&gt;&gt; </code></pre> <p>But when I run it in the command line, i get this:</p> <pre><code>&gt;&gt;&gt; dir(sys) ['__displayhook__', '__doc__', '__excepthook__', '__name__', '__package__', '__stderr__', '__stdin__', '__stdout__', '_clear_type_cache', '_current_frames', '_getframe', '_mercurial', 'api_version', 'argv', 'builtin_module_names', 'byteorder', 'call_tracing', 'callstats', 'copyright', 'displayhook', 'dllhandle', 'dont_write_bytecode', 'exc_clear', 'exc_info', 'exc_traceback', 'exc_type', 'exc_value', 'excepthook', 'exec_prefix', 'executable', 'exit', 'flags', 'float_info', 'float_repr_style', 'getcheckinterval', 'getdefaultencoding', 'getfilesystemencoding', 'getprofile', 'getrecursionlimit', 'getrefcount', 'getsizeof', 'gettrace', 'getwindowsversion', 'hexversion', 'long_info', 'maxint', 'maxsize', 'maxunicode', 'meta_path', 'modules', 'path', 'path_hooks', 'path_importer_cache', 'platform', 'prefix', 'py3kwarning', 'setcheckinterval', 'setprofile', 'setrecursionlimit', 'settrace', 'stderr', 'stdin', 'stdout', 'subversion', 'version', 'version_info', 'warnoptions', 'winver'] </code></pre> <p>Can someone explain the difference in what I did?</p>
python
[7]
5,820,330
5,820,331
Facial Expression recognition
<p>I want to do project on Facial Expression Recognition.It will be to detect the expressions of a person using neural networks e.g happy,sad etc.Is it possible in java?? </p>
java
[1]
4,468,938
4,468,939
Why should I not instantiate a string object with a constructor?
<p>In Java, apparently, <code>String s = "foo"</code> is preferred over <code>String s = new String("foo")</code>.</p> <p>Why? Isn't a new string object created in both cases? Why would the first case preclude calling a constructor?</p>
java
[1]
5,667,960
5,667,961
Sending Variable from one function to another php function
<p>I am trying to send a variable from a public function to a private static function as follows:</p> <pre><code>public function getAirportFare($fare) { $fare2 = 1000; return self::getFinalFare($fare, $fare2); } </code></pre> <p>TO:</p> <pre><code>private static function getFinalFare($fare, $fare2) { $fare = $fare + $fare2; $final_fare = ($fare * self::$fare_factor); if (self::$str_wait_return == "true") { $final_fare = $final_fare * 2; } if (self::$str_return == "true" &amp;&amp; self::$return_date != "false" &amp;&amp; self::$return_time != "false") { // We need to calc to fare based on the return date and time $return_fare = self::getFare(1); // Append to final fare $final_fare = $final_fare + $return_fare; } return number_format($final_fare,2); } </code></pre> <p>but $fare2 in the getFinalFare function is undefined? I was just wondering how I can pass this value?</p>
php
[2]
217,250
217,251
Compile Error: illegal start of expression
<p>I'm learning Java (The Gaming Side). I bought a book and it has some code in which I tried to copy and test it. The only problem is that it comes up with errors when I try to compile it.</p> <pre><code>C:\Users\James\Desktop\Java&gt;Javac GamePanel.java GamePanel.java:57: illegal start of expression private void gameUpdate() ^ GamePanel.java:57: illegal start of expression private void gameUpdate() ^ GamePanel.java:57: ';' expected private void gameUpdate() ^ GamePanel.java:64: reached end of file while parsing }→ ^ 4 errors </code></pre> <p>The code is:</p> <pre><code>public class GamePanel extends JPanel implements Runnable { private static final int PWIDTH = 500; private static final int PHEIGHT = 400; private Thread animator; private volatile boolean running = false; private volatile boolean gameOver = false; public GamePanel() { setBackground(Color.white); setPreferredSize( newDimension(PWIDTH, PHEIGHT)); } public void addNotify() { super.addNotify(); startGame(); } public void startGame() { if (animator == null || !running) { animator = new Thread(this); animator.start(); } } public void stopGame() { running = false; } public void run() { running = true; while(running) { gameUpdate(); gameRender(); repaint(); try { Thread.sleep(20); } catch(InterruptedException ex) { } System.exit(0); } private void gameUpdate() { if (gameOver == false) { } } } </code></pre> <p>I know I'm probably doing something wrong but I checked it over and over again, can someone please enlighten me on what I am doing wrong?</p>
java
[1]
1,124,394
1,124,395
string inside array, quotes or no quotes
<p>When i assign a key value into an array of type string, does it have to be in quotes?</p> <pre><code>define('ALBUM_COVER_50', '../discography/artwork/cover/50/'); define('ALBUM_COVER_ZOOM', '../discography/artwork/cover/800/'); $selected_artwork = array(); $cover = 'greatesthits_cs23409.jpg'; $selected_artwork[ALBUM_COVER_50.$cover] = ALBUM_COVER_ZOOM.$cover; </code></pre> <p>In the above snippet, do i have to put <code>ALBUM_COVER_50.$cover</code> in quotes like:</p> <pre><code>$selected_artwork['\''.ALBUM_COVER_50.$cover.'\''] = ALBUM_COVER_ZOOM.$cover; </code></pre> <p>What is the best practice to go about this issue?</p>
php
[2]
1,944,339
1,944,340
Problem with Synchronization
<p>I have the following sample piece of code,</p> <pre><code>public class test implements Runnable{ public void run() { synchronized(this) { for(int i=0;i&lt;10000;i++) System.out.println(i); } } public static void main(String args[]) throws Exception { Thread t=new Thread(new test()); t.start(); //Thread.sleep(100); t.suspend(); System.out.println("Hi"); } } </code></pre> <p>I have the following requirement,When the thread is suspended it must execute all the iterations of the loop without getting suspended. I felt that synchronized is for this purpose but it didnot solve the problem. When i suspend a thread if it is in a synchronized block then it must get suspended only after the block is executed. What java construct can be used for this?</p>
java
[1]
2,674,513
2,674,514
Javascript syntactic sugar for object value setter
<p>Is there an easy way to do this in one line</p> <pre><code>( node.innerText || node.textContent ) = text // node = DOM node // text = string </code></pre> <p>Obviously the above does not work. </p>
javascript
[3]
4,278,675
4,278,676
Using issue, why do I have to use using global::MyName.SubName?
<p>I have a library project in my solution that I just added, and whenever I need to reference a class/enum I have to use:</p> <p><code>using global::MyName.SubName;</code></p> <p>(Resharper automatically suggests this)</p> <p>Why is this? Why can't I just do:</p> <pre><code>using MyName.SubName; </code></pre> <p>Which doesn't work. And even when it does this I am getting this error:</p> <pre><code>Error 400 Member 'MyName.SubName.Enumerations.SomeEnum.SomeEnumName1' cannot be accessed with an instance reference; qualify it with a type name instead </code></pre>
c#
[0]
4,426,029
4,426,030
Is there a way find to find out if a software keyboard is shown?
<p>My actual <code>UITextField</code> control is embedded many layers down in an external library. Therefore I am unable to detect if it is being edited by calling </p> <p><code>control isFirstResponder</code>. </p> <p>Is there another way to detect if the software keyboard is shown?</p>
iphone
[8]
4,127,177
4,127,178
Function only works with jquery 1.1.2 anyone know why?
<p>hey guys, I am starting to get frustrated. I have a function I am using to fade a comment in after it is inserted. It works only with jquery 1.1.2 however, so none of the other functions on my page will work. If I try to use it with a newer version, comments will not show up since display is set to none in css so that comments can be faded. Does anyone know of a modification to make it work with jquery 1.3.2?</p> <pre><code> function success(response, status) { if(status == 'success') { lastTime = response.time; $('#daddy-shoutbox-list').append(prepare(response)); $('input[@name=message]').attr('value', '').focus(); $('#list-'+count).fadeIn('slow'); timeoutID = setTimeout(refresh, 3000); } } </code></pre>
jquery
[5]
1,557,161
1,557,162
ASP.NET Grid View Problem
<p>I have one gridview where I am passing the command argument as gridview row id for the Button I created for every row.</p> <p>I want to display all the details of that row in the textbox according to the Row clicked.</p> <pre><code>&lt;asp:GridView ID="gvCategory" runat="server" AutoGenerateColumns="false" onrowcommand="gvCategory_RowCommand" &gt; &lt;Columns&gt; &lt;asp:TemplateField&gt; &lt;ItemTemplate&gt; &lt;asp:Label ID="lblCatId" runat="server" Text='&lt;%#Eval("categoryId") %&gt;'&gt;&lt;/asp:Label&gt; &lt;/ItemTemplate&gt; &lt;/asp:TemplateField&gt; &lt;asp:TemplateField&gt; &lt;ItemTemplate&gt; &lt;asp:Label ID="lblCatName" runat="server" Text='&lt;%#Eval("categoryName") %&gt;'&gt;&lt;/asp:Label&gt; &lt;/ItemTemplate&gt; &lt;/asp:TemplateField&gt; &lt;asp:TemplateField&gt; &lt;ItemTemplate&gt; &lt;asp:Button ID="btnModify" runat="server" Text="Modify" CommandName="Modify" CommandArgument='&lt;%#Eval("categoryId") %&gt;' /&gt; &lt;/ItemTemplate&gt; &lt;/asp:TemplateField&gt; &lt;/Columns&gt; &lt;/asp:GridView&gt; </code></pre> <p>Code.....</p> <pre><code>if (e.CommandName == "Modify") { int id = Convert.ToInt32(e.CommandArgument); // I want the value to assgin for the selected row here // I was previously fetching the data from database according id,but i want this frim the gridview of selected row. } </code></pre>
asp.net
[9]
2,580,642
2,580,643
jquery - select the next item of this in each() function
<p>I want to select the next element of this in each() function. check out the code comments</p> <pre><code>$(function(){ var selects = $('body').find('span'); selects.each(function(index,el){ if(index==0){ //remove the next span of this, which is span2 } }); }); &lt;body&gt; &lt;div&gt; &lt;span&gt;1&lt;/span&gt; &lt;/div&gt; &lt;span&gt;2&lt;/span&gt; &lt;div&gt; &lt;span&gt;3&lt;/span&gt; &lt;/div&gt; &lt;/body&gt; </code></pre>
jquery
[5]
5,061,667
5,061,668
Can't delete a file
<p>A have such a problem: there are some RandomAccessFiles which are opened through the algorithm. The function they are used in is recursive. SO I can't close them (if I do, I will crash the algorithm). Are there any way to close them (to delete afterwards)? </p>
java
[1]
2,800,471
2,800,472
Base64 encode uploaded file then save in database
<p>I want to base 64 encode uploaded file then save this into Blob type column of a table in MySQL database.</p> <p>I have tried built in PHP function base64_encode with file variable but this does not seem to work.</p> <p>Is there a way we can do this?</p> <p>The reason is that I do not want to use moveuploaded file into a folder.</p> <p>Thank you.</p>
php
[2]
380,377
380,378
What is "Integer.valueOf().intValue()" supposed to do?
<p>Here is a java line of code that i have failed to understand. </p> <pre><code> String line = "Some data";//I understand this line int size;//I understand this line too size = Integer.valueOf(line,16).intValue();//Don't understand this one </code></pre> <p>What i know is <strong>Integer.ValueOf(line</strong>) is the same as <strong>Integer.parseInt(line)</strong> , is not so? Correct me if i am wrong; Thanks.</p>
java
[1]
2,580,028
2,580,029
Android textview gravity center
<p>I have this layout:</p> <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#222222" android:gravity="center_horizontal" android:layout_gravity="center_horizontal" android:paddingBottom="5dp"&gt; &lt;SeekBar android:layout_width="200dp" android:layout_height="wrap_content" android:id="@+id/seekbar" android:max="5" android:progress="2"&gt; &lt;/SeekBar&gt; &lt;TextView android:id="@+id/fontsize00" android:layout_width="25dp" android:layout_height="25dp" android:gravity="center" android:layout_marginLeft="20dp" android:text="C" android:textSize="20dp" android:background="#FFFFFF" android:textColor="#222222"&gt; &lt;/TextView&gt; &lt;/LinearLayout&gt; </code></pre> <p>The size of the text changes with the change of the value of the spinner. Even if at low values the text is in the center of the textview, at bigger values it is set lower. Why is this happening? <img src="http://i.stack.imgur.com/YMNWg.png" alt="enter image description here"></p>
android
[4]
3,729,779
3,729,780
bind mouse event with fading
<p>I am using the following code to fade between images in my menu items on mouseover...</p> <pre><code> $(document).ready(function() { $('nav li').each(function() { var bgPos = $(this).css('background-position'); $(this).css('background-position', bgPos); $(this).removeAttr('id'); bgPos = bgPos.split(' '); var position = $(this).position(); var cssObj = { 'position' : 'absolute', 'top' : position.top, 'left' : position.left, 'background-position' : bgPos[0]+' -115px' } var outcome = $('&lt;li&gt;&lt;/li&gt;').hide(); $(outcome).css(cssObj); $(this).parents('.nav').append(outcome); $(this).data('clone', outcome); $(this).bind({ mouseenter: function() { $(this).data('clone').fadeIn(1000); }, mouseout: function() { $(this).data('clone').fadeOut(300); } }); }); }); </code></pre> <p>The problem is because when fadeout completes the display on the faded element turns to none, jQuery thinks I have mouseentered again even though my mouse hasnt moved and I end up with an endless loop of fading in then fading out.</p>
jquery
[5]
1,791,431
1,791,432
TimeStamp Standard PHP
<p>I am working on creating a log file where log details including timestamp should be written to the log file. But is there any standard timestamp function which I can use in the php code which does not show any sort of errors like "You cannot rely on SYstem's timezone' etc . Thanks</p>
php
[2]
2,580,205
2,580,206
find caller script path from a library
<p>When execution a script that includes a library, I whant to find from whithin the library the caller script, in Perl I'm using env: <code>$0</code> that gives me the path to the caller script. In PHP <code>__FILE__</code> gives me the current script, so in the library it gives me the library path not the caller script path.</p> <p>from perl documentation: <strong>$0 Contains the name of the file containing the Perl script being executed.</strong> </p> <p>I think It can be done using debug_backtrace(), but there is another better/shorter method ?</p> <p><strong>EDIT:</strong> (added sample code) </p> <p>file: index.php</p> <pre><code>&lt;?php require 'locallib.php'; echo 'in original script = '.__FILE__.'&lt;br /&gt;'; ?&gt; </code></pre> <p>file: locallib.php</p> <pre><code>&lt;?php require "lib.php"; echo 'in library "'.__FILE__.'"&lt;br /&gt;'; ?&gt; </code></pre> <p>file: lib.php</p> <pre><code>&lt;?php if( $_SERVER['SCRIPT_FILENAME'] != '/var/www/html/index.php') { echo "Not allowed";exit; } else { echo 'in library "'.__FILE__.'"&lt;br /&gt;'; echo '&lt;pre&gt;'; print_r($_SERVER); echo '&lt;/pre&gt;'; } ?&gt; </code></pre>
php
[2]
5,412,610
5,412,611
custom listview with popup problem in android
<p>my custom listvalues are coming from java bean I have popup inside custom list view with textview, check box and I have list view in activity if user select check box in popup I have to add checked value in list view can anybody tell how to do give example </p> <p>Thanks</p>
android
[4]
3,118,876
3,118,877
replace child at particular index of viewflipper android
<p>In my android application i am using view flipper for implementing pagination.<br> I am normally adding listviews as child for view flipper.If the user click on change view button this listviews should be deleted and replaced with gallery view. </p> <p>Please let me know as how can i delete child at particular index and then add another layout at same index of view flipper. </p> <p>Please forward your valuable suggestions</p>
android
[4]
2,846,133
2,846,134
output the result of a query of a database?
<p>Hello i got a problem with my mysql code it gives the following error upon trying to output:</p> <pre><code>Parse error: syntax error, unexpected $end in C:\xampplite\htdocs\learncent\acksearch\search.php on line 25 </code></pre> <p><br /></p> <pre><code>&lt;?php $db = new mysqli("localhost","root","","acksocial"); if(mysqli_connect_error()) { printf("Connection failed:%s \n",mysqli_connect_error()); exit(); } $name = mysqli_real_escape_string($db, $_POST['search']); $table = 'acksearch'; if($result = $db-&gt;query("SELECT * FROM $table WHERE name = $name", MYSQLI_ASSOC)) { while($row = $result-&gt;fetch_object()) { // $row is an associative array // Do something here echo "Name: ".$row['name']; echo " country: ".$row['country']; } $db-&gt;close(); ?&gt; </code></pre> <p>EDIT: added 1 more } and no error but it wont output the result?</p> <p>Would be good if anyone could help me.</p> <p>EDIT AGAIN : Now the code look like this</p> <pre><code>&lt;?php $db = new mysqli("localhost","root","","acksocial"); if(mysqli_connect_error()) { printf("Connection failed:%s \n",mysqli_connect_error()); exit(); } $name = mysqli_real_escape_string($db, $_POST['search']); $table = 'acksearch'; if($result = $db-&gt;query("SELECT * FROM $table WHERE name = $name", MYSQLI_ASSOC)) { while($row = $result-&gt;fetch_object()) { // $row is an associative array // Do something here echo "Name: ".$row['name']; echo " country: ".$row['country']; } </code></pre> <p>The error its giving its:</p> <pre><code>Parse error: syntax error, unexpected $end in C:\xampplite\htdocs\searcher.php on line 25 </code></pre> <p>Thanks Fredrik</p>
php
[2]
2,031,385
2,031,386
Setting include path in PHP intermittently fails. Why?
<p>I have tried both </p> <pre><code>ini_set('include_path', '.:/usr/share/php5:/usr/share/php5/PEAR:lib:app/classes'); </code></pre> <p>in the code itself and also</p> <pre><code>php_value include_path ".:/usr/share/php5:/usr/share/php5/PEAR:lib:app/classes" </code></pre> <p>in the .htaccess file.</p> <p>Both methods actually <strong>do work</strong> but only intermittently. That is, they will work fine for about 37 pages requests and then fail about 42 pages requests resulting in an require() call to cause a fatal error effectively crashing the site.</p> <p>I'm not even sure where to begin trying to find out what is going on!</p> <p><hr /></p> <p>@<a href="http://stackoverflow.com/questions/41836/setting-include-path-in-php-intermittently-fails-why#41877" rel="nofollow">cnote</a></p> <blockquote> <p>Looks like you duplicated the current directory in your include path. Try removing one of the '.:' from your string.</p> </blockquote> <p>The in script version was originally </p> <pre><code>ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . 'lib' . PATH_SEPARATOR . 'app' . DIRECTORY_SEPARATOR . 'classes'); </code></pre> <p>and thus the .:.: was coming from the existing path:</p> <pre><code>ini_get('include_path') </code></pre> <p>I tried removing it anyway and the problem persists.</p>
php
[2]
5,214,702
5,214,703
How can i add contact info to iphone app
<p>I have developed an iphone app. How can i add my developer email to the app? So that users can contact me? I dont see any option like android market where you can add your contact email so that if any users have questions they can contact you directly?</p>
iphone
[8]
2,225,813
2,225,814
Jquery - Read all Classes from a div
<p><br /> i try to read all classes.</p> <p><strong>HTML</strong></p> <pre><code>&lt;div id="test" class="fff aaa ccc" &gt;hello world&lt;/div&gt; </code></pre> <p><strong>JS</strong></p> <pre><code>if ($('#test').attr('class') != '') { // Read classes var all_classes = $('#test').attr('class'); // Output $('body').append('Classnames: '+all_classes+' '); } </code></pre> <p><strong>Example</strong> <a href="http://www.jsfiddle.net/AQgqU/8/" rel="nofollow">http://www.jsfiddle.net/AQgqU/8/</a></p> <p>Can somebody help me?</p> <p>Thanks in advance!<br /> Peter</p>
jquery
[5]
5,976,929
5,976,930
Java: Converting data types
<p>I'm working with a <code>JTable</code>, whose cells data are contained in <code>Object</code>. One column shows a <code>float</code> number. I want to GET the value into a<code>float</code>, limit decimal places to 3, and then I want to reload the correct data in the cell, so I want to SET the value into the cell again. The problem appears in the last conversion:</p> <pre><code> private class CambioTablaMeasurementListener implements TableModelListener{ public void tableChanged(TableModelEvent e){ try{ if(sendDataToDisp){ TableModel model = (TableModel)e.getSource(); float value = Float.parseFloat((String)model.getValueAt(e.getLastRow(), 1)); // Now i want to limit to only 3 decimal places, so: double aux = Math.round(value*1000.0)/1000.0; value = (float) aux; Float F = new Float(value); // Now i want to load data back to the cell, so if you enter 0.55555, the cell shows 0.555. This Line gives me an exception (java.lang.Float cannot be cast to java.lang.String): model.setValueAt(F, e.getLastRow(), 1); // Here I'm getting another column, no problem here: String nombreAtributo = (String)model.getValueAt(e.getLastRow(), 0); nodoAModificar.setCommonUserParameter(nombreAtributo, value); } ...} </code></pre>
java
[1]
2,736,991
2,736,992
How to learn C++ for the purposes of debugging
<p>Some background: My job involves maintaining a large multi-threaded multi-process C++ / C# application, and so I'm often tasked with understanding access violations, memory leaks, heap curruption issues and the like.</p> <p>I quite enjoy this, and I've amassed quite a good understanding of various low level concepts, but the trouble is that <strong>I don't program in C++</strong>, and aside for the purposes of maintenance I don't really intend to.</p> <p>What I mean by that is that if I ever need to develop something then at the company I work at the best choice is C# (more developers, other apps also in C# means better interops), so its not that I don't program in C++, it's just that whenever I do program in C++ it will be <strong>purely</strong> for the purpose of learning C++, and <strong>so I want to get the most out of it</strong>.</p> <p>My view is that "Teach yourself C++" books and the like aren't very suitable as they focus too much on getting things done - there are usually many ways of doing things and so they tend to pick one method, so when I'm presented with some code that does things a different way I'm stuffed (e.g. a book teaches MFC, I then get presented with some ATL code and the book hasn't even taught me what ATL and MFC are, let alone how to recognise that what I'm looking at is different!)</p> <p>I'm really looking for teach yourself C++, <strong>with the emphasis on understanding other peoples code</strong>.</p>
c++
[6]
3,951,581
3,951,582
Detect click on a specified area
<pre><code>&lt;div id="main"&gt; hello world &lt;div id="second-div"&gt; bye &lt;/div&gt; &lt;/div&gt; jQuery('#main:not(second-div)').click(function() { alert('works!'); }); </code></pre> <p>I want to detect mouse click on the "main" div, but the click event shouldn't trigger when I click on the "second-div" div. I've tried using ":not(second-div)" but the click triggers anyway.</p>
jquery
[5]
4,170,867
4,170,868
know of a good tutorial for posting status updates to facebook?
<p>I'm looking for a tutorial for updating Facebook status in PHP. Any suggestions?</p>
php
[2]
5,293,589
5,293,590
How do I remove this div from the dom?
<p>Using jQuery, how do I remove the #hello div below and just keep the <code>a</code> element within the outer div tags?</p> <p>I want to go from this:</p> <pre><code>&lt;div&gt; &lt;div id="hello"&gt; &lt;a href="http://google.com"&gt;&lt;/a&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>To this:</p> <pre><code>&lt;div&gt; &lt;a href="http://google.com"&gt;&lt;/a&gt; &lt;/div&gt; </code></pre>
jquery
[5]
1,243,050
1,243,051
android: radiobuttons aligned vertical and horizontal in same radiogroup
<p>I would like to have radiobuttons in one radiogroup divided into 2 columns and several rows. So far i have been able to divide them in a way that i put LinearLayouts inside radiogroup. Problem is they are not exclusive when I click on them (I can check all of them at the same time). Is there a way to make them exclusive (beside programmatic way)? Thank you</p>
android
[4]
5,820,369
5,820,370
How to Convert image to NSData And that NSData To NSString
<p>Here is the code i am Trying </p> <pre><code>NSData *imageData = [[NSData alloc]initWithData:UIImagePNGRepresentation(myImage.image)]; imageClass.imageString = [[NSString alloc]initWithData:imageData encoding:NSUTF8StringEncoding]; NSLog(@"String is :%@",imageClass.imageString); // getting NULL </code></pre> <p>getting String is :null </p>
iphone
[8]
1,688,949
1,688,950
Getting started with python development?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/17988/how-to-learn-python">How to learn Python?</a> </p> </blockquote> <p>I'm looking for some good resources (books, tutorials, sites, etc) for getting started with Python development.</p> <p>Note, not <a href="http://stackoverflow.com/questions/3154921/good-resources-to-start-python-for-web-development">web-specific like this question</a>, just python in general.</p>
python
[7]
4,899,410
4,899,411
How to run two netbeans project on different systems
<p>I am working on a project on the topic implementation of parallel query processing features in PostgreSQL. As a part of my project i would like to connect two netbeans project on different systems and run them simultaneously. Can any one help me.</p>
java
[1]
1,381,471
1,381,472
Print out everything inside array in php
<p>can anyone explain why I can't see what's inside the array? I think it supposed to be able to have multiple numbers (subscriptions) so maybe that's why I'm having trouble? Here's the code. </p> <pre><code> $num = $_SESSION['subscription_ids']; if(is_array($num)) { print_r($num); } else { echo "not an array"; } //Thanks DonnieM, yet It's spliting out "Array ( ) " no joke. </code></pre> <p>What is going on?</p>
php
[2]
1,791,711
1,791,712
Best way to reset keys which expires in few minutes in python
<p>I have to reset my key (something like session key) every two hours, which is going to expire after that. which is the best way to implement a reactivation feature in my code?</p> <p>there is no method available for me to check whether my key is still valid other than checking the status by performing some actions which require valid keys.</p> <p>I'm looking for some solution with which i can use it for flexible expiring time (which is passed as a parameter) for my key.</p>
python
[7]
2,551,283
2,551,284
User defined number ranges
<p>I have a function where for a specific number range a percentage has to be applied:</p> <ul> <li>0-100 EUR: 5%</li> <li>>100 EUR: 3%</li> </ul> <p>This number ranges and percentages should be <strong>user-defined</strong>.</p> <p>The implementation should be as simple as possible.</p> <p>What would you suggest for specifying the ranges and calculating the result?</p>
php
[2]
628,578
628,579
Library not found for -lclientrt
<p>I am trying to deploy Sample application(SUP101Sample) on iPhone device. I am using Sybase unwired platform 2.1 ESD #1.</p> <p>I tried to build the app on both simulator as well as in iOS device but in both the cases it is giving the common error </p> <blockquote> <p>library not found for -lclientrt</p> </blockquote> <p>I have added all the libraries which ever mentioned in the tutorial <a href="http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.infocenter.dc01213.0210/doc/html/title.html" rel="nofollow">SYBASE</a></p> <pre><code>I am using Mac OSX 10.7.3, Xcode Version 4.3.1 and iOS 5.1 </code></pre>
iphone
[8]
1,321,893
1,321,894
Add more than two variable into one variable in jquery
<p>Hi I am getting all the a tag attributes using jquery function, now I want to store them into one and append in body, but cant find the way how to get it done. Here is <a href="http://jsfiddle.net/cuyfK/" rel="nofollow">fiddle</a> link</p> <pre><code>&lt;head&gt; &lt;script type="text/javascript"&gt; $(function(){ $('a').click(function(){ var name= $(this).attr('name'); var href= $(this).attr('href'); var jj= $(this).attr('class'); var user_id= $(this).attr('user_id'); var page_type= $(this).attr('page_type'); var price= $(this).attr('price'); var bonus= $(this).attr('bonus'); var wrapper= $(this).attr('wrapper'); var token= $(this).attr('token'); var own= $(this).attr('own'); $('body').append('&lt;div&gt;'+name+'&lt;div&gt;') })}) &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;a id="profile_2902" name="b_now" href="#" class="big_now" user_id="152402569967" page_type="profile" price="292" bonus="0" wrapper="5972569967" token="e644ce48aa43dc3caa348745a" own="4100447132"&gt; Click now! &lt;/a&gt; &lt;/body&gt; </code></pre>
jquery
[5]
3,163,759
3,163,760
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]
3,879,805
3,879,806
How can I, in python, iterate over multiple 2d lists at once, cleanly?
<p>If I'm making a simple grid based game, for example, I might have a few 2d lists. One might be for terrain, another might be for objects, etc. Unfortunately, when I need to iterate over the lists and have the contents of a square in one list affect part of another list, I have to do something like this.</p> <pre><code>for i in range(len(alist)): for j in range(len(alist[i])): if alist[i][j].isWhatever: blist[i][j].doSomething() </code></pre> <p>Is there a nicer way to do something like this?</p>
python
[7]
3,863,167
3,863,168
Service exiting after last client unbinds, even though startService() called beforehand?
<p>I have an app that has a client Activity and a long-running Service. The Service may be started by the alarm manager or by the Activity itself. </p> <p>The alarm intent calls startService(). The Activity calls startService, and then binds itself to the service so it can get information from it.</p> <p>When I back-button out of the Activity, onDestroy() is called on the Activity, the Activity unbinds from the Service, and onDestroy() is called on the Service. </p> <p>I was under the impression that if I called startService(), then the Service would stay around until stopService()/stopSelf() was called, no matter what clients have unbound from it.</p> <p>Am I misunderstanding something?</p>
android
[4]
3,682,887
3,682,888
python, how to call function in as parameter in self.response.out.write()
<pre><code>class GuestBook(webapp.RequestHandler): def post(self): self.response.out.write( '&lt;h2&gt;You wrote:&lt;/h2&gt; %s' %self.request.get('content') ) </code></pre> <p>I want to pass this: <code>%self.request.get('content')</code> into a function. And use function return in the old place.I am python newbie. I tried.but failed. need help!</p> <p>This is my function; I defined it in the same class as below.</p> <pre><code>def ept(str) str = str + " is good." return str </code></pre> <p>And I call it in the old place like:</p> <pre><code>ept(%self.request.get('content')) </code></pre> <p>Could anybody help me, what is wrong with my code</p>
python
[7]
1,718,825
1,718,826
Retrieve and Remove elements from string
<p>Say I have a list of string </p> <pre><code>List&lt;string&gt; lst=new List&lt;string&gt;(new string[]{"a","b","c","d"}); </code></pre> <p>I wish to get element from index 0 to index 2 assign it to another List lst1(i.e. the element of lst is <code>{"a","b"}</code>), then remove it from lst (i.e. lst becomes <code>{"c","d"}</code>, what's the quickest way of doing this? I am thinking is there any command like</p> <pre><code>List&lt;string&gt; lst=new List&lt;string&gt;(); lst1=lst.getElements(1,2); lst.remove(1,2); </code></pre>
c#
[0]
150,703
150,704
How to round up a number
<p>I have variable like float num = (x/y); I need to round up the result whenever num gives result like 34.443. So how to do this in c#? </p>
c#
[0]
4,081,831
4,081,832
Count how many strings in an array have duplicates in the same array
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/8607455/array-value-count-javascript">Array value count javascript</a> </p> </blockquote> <p>I have an array which contains several duplicates, what I'm trying to achieve is to count how many duplicates each unique string has in this one array.</p> <p>The array looks something like this</p> <pre><code>array = ['aa','bb','cc','aa','ss','aa','bb']; </code></pre> <p>Thus I would like to do something like this</p> <pre><code>if (xWordOccurrences &gt;= 5) { // do something } </code></pre> <p>But I'm not sure how I would code this. I was thinking, create an object with each unique string, then loop through the original array, match each string with it's object and increment it's number by 1, then loop over the object to see which words had the most duplicates... </p> <p>But this seems like an over complexe way to do it.</p>
javascript
[3]
5,478,575
5,478,576
Which PHP function to use to read a binary file into a string?
<p>Which PHP function to use to read a binary file into a string?</p>
php
[2]
4,216,990
4,216,991
Are public accessors needed for an inner class, if only accessed from the outer class?
<p>Since i can access <code>private</code> variables of an inner class directly and ... the only way to access <code>inner</code> class is via the <code>outer</code> class .. <strong>is there any value in having public accessor/ mutator methods for an inner class?</strong></p> <pre><code>public class Outer { Inner i; Outer() { i.v = 5; } private class Inner { private int v; } } </code></pre> <p>For the purposes of this question, assume that no lazy instantiation or other data manipulation is needed upon access.</p>
java
[1]
2,920,150
2,920,151
Convert character value to hexa in java
<p>I have method to covert character to haxa like </p> <pre><code>private static String convert(char str) { StringBuffer ostr = new StringBuffer(); String hex = Integer.toHexString(str &amp; 0xFFFF); for(int j=0; j&lt;4-hex.length(); j++) ostr.append("0"); ostr.append(hex.toUpperCase()); return (new String(ostr)); } </code></pre> <p>Its work fine for window but create problem for linux. Can any one suggest me how to do same thing in linux ?</p>
java
[1]
2,798,755
2,798,756
How to add image Bitmap in the Gallery component?
<p>Is there any way to insert a bitmap image in the gallery component?</p>
android
[4]
22,709
22,710
Hiding divs dynamically using a search
<p>JSFiddle for what I have done so far <a href="http://jsfiddle.net/chQ2T/3/" rel="nofollow">http://jsfiddle.net/chQ2T/3/</a></p> <p>As you can see, I have some divs arranged thus</p> <p></p> <pre><code>&lt;div id = "container"&gt; &lt;div id = "abc" class = "box"&gt; ABC &lt;/div&gt; &lt;div id = "cde" class = "box"&gt; CDE &lt;/div&gt; &lt;div id = "efg" class = "box"&gt; EFG &lt;/div&gt; &lt;/div&gt; </code></pre> <p>And there is a search box where I want to dynamically hide and show divs based on the search query (executed after every stroke) and the div id. So typing <code>c</code> should hide all divs where the id does not contain substring "c" i.e. the last one.</p> <p>Typing <code>d</code> after that should hide the additional div abc, since it does not contain the substring "cd". Backspace should restore it. So basically it's a standard dynamic search.</p> <p>What is missing are the Javascript functions for hiding and showing.</p> <pre><code>function hide_divs(search) { $("#container").not("#"+search).hide(); } $(document).ready(function() { $("#search_field").keyup(function() { var search = $.trim(this.value); hide_divs(search); }); }); </code></pre> <p>I am struggling with restoring the previously hidden divs.</p>
javascript
[3]
1,640,639
1,640,640
Java text highliting
<p>I did a code in java for file comparison. This compares two file contents and gives a result like : modified line and deleted lines and blank lines. I want them to highlight with different color. (Same as a file compare software does).</p> <p>Thanks in advance.</p> <p>Nitin</p>
java
[1]
3,978,638
3,978,639
CallLog.Calls Query By Date
<p>I am querying CallLog.Calls content provider for call details. Everything works fine except when I try to query by dates. That is, to get call details for a particular date or date range etc. I know the date are stored as long (millisecond format) so I tried to convert the date first and then query by it, but I must be doing something wrong here. Here's the query I am running, pls note that it works well when I remove the "WHERE DATE =" part or replace it by something like "WHERE TYPE=" etc. So, how do I run a query to get call details for a date or date range? Any help on this? Thanks. </p> <pre><code>Cursor c = getContentResolver().query(CallLog.Calls.CONTENT_URI, null, CallLog.Calls.DATE + "&lt;=?", new String[] { String.valueOf(dateSTR)}, ORDER_BY); startManagingCursor(c); </code></pre>
android
[4]
4,788,823
4,788,824
PHP if statement ELSE not working
<p>I am having an odd problem. This if statement is running as if the condition is being met.. It is not being met. I want the else statement to get executed but it won't. What am I doing wrong?</p> <pre><code>&lt;?php $count=2; if ($count=1) { echo "hello"; } else { echo "goodbye"; } ?&gt; </code></pre>
php
[2]
5,932,055
5,932,056
Function with return value char* returning garbage
<p>I'm trying to build a utility class that I can re-use, that converts a <code>std::string to a char*</code>:</p> <pre><code>char* Foo::stringConvert(std::string str){ std::string newstr = str; // Convert std::string to char* boost::scoped_array&lt;char&gt; writable(new char[newstr.size() + 1]); std::copy(newstr.begin(), newstr.end(), writable.get()); writable[newstr.size()] = '\0'; // Get the char* from the modified std::string return writable.get(); } </code></pre> <p>The code works when I tried to load the output from within the stringConvert function, however when used in other parts of my application, this function returns garbage.</p> <p>For example:</p> <pre><code>Foo foo; char* bar = foo.stringConvert(str); </code></pre> <p>The above code returns garbage. Is there any workaround for this kind of issue?</p>
c++
[6]
5,843,701
5,843,702
scattering effect
<p>I went through all my resources but I am not getting the scattering effect of an image smoothly. However, I am able to zoom it and I had scattered it but it is not as smooth as I want. I just want to click on a button and it should zoom and the other image should get scatter</p> <p>I want the image to be scattered as the link given below is it possible in iPhone? <a href="http://www.touchmagix.com/templates/diamond.htm" rel="nofollow">http://www.touchmagix.com/templates/diamond.htm</a></p>
iphone
[8]
2,239,852
2,239,853
Generating a random turtle function in python
<p>I'm trying to write a function called randomTurtle():</p> <ul> <li>generate a random number between 0 and 100 (0 and 100 included) that will determine the total number of moves the turtle will make (in other words, how many times the turtle will loop through)</li> </ul> <p>Then For each repetition of the sequence): Generate a random number of steps between 1 and 50 (1 and 50 included). </p> <p>Move the turtle forward by that amount. </p> <p>Select a random float between 0 and 1. If the value is less than 0.5, turn the turtle right. If the value is greater than or equal to 0.5, turn the turtle left</p>
python
[7]
4,010,103
4,010,104
Android: Convert pdf to images
<p>i m receiving a <strong>pdf</strong> file from the server &amp; want to display it as images..</p> <p>So is der a way to convert this pdf file to Images?</p> <p><strong>UPDATE:</strong></p> <p>Can i do this thru <a href="http://developer.android.com/reference/android/provider/MediaStore.Files.html" rel="nofollow">MediaStore</a>? If not, how can i do this thru PDFBox API???</p> <p>Thanks, Nital Shah</p>
android
[4]
32,997
32,998
Cannot update the project in android ndk
<p>I'm using linux and i have successfully installed ndk and configured it. with the help of <a href="http://developer.android.com/sdk/ndk/index.html" rel="nofollow">Android NDK installation</a> But i can't able to generate build.xml file</p> <pre><code>root@ndot-173:~/Desktop/NDK4/samples/bitmap-plasma# android update project -p . -s android: command not found </code></pre> <p>It shows command not found. How do i generate build.xml file..?</p>
android
[4]
5,235,363
5,235,364
Python - Prime Number exercise
<p>Note, this is not my homework assignment! I'm just trying to understand Python (and math, sadly) at the same time. I know the ultimate goal of this program is to get a list of prime numbers in the range 1 to 20, however, once it gets to the "for x in range..." line, I'm getting lost and the tutorial doesn't explain it in detail. </p> <p>Could you please explain in plain English step by step and clarify specifically</p> <p>a) what is x in the line <code>for x in range (2,n)</code></p> <p>b) in the line <code>for x in range (2,n),</code> what is <code>n</code>? Is it the same "n" at the bottom?</p> <p>c) what is this <code>n, x, n // x</code> saying exactly. Please clarify the <code>//</code></p> <p>thanks if you can help</p> <pre><code>def isprime(n): if n == 1: print("1 is special") return False for x in range(2, n): if n % x == 0: print("{} equals {} x {}".format(n, x, n // x)) return False else: print(n, "is a prime number") return True for n in range(1, 20): isprime(n) </code></pre>
python
[7]
5,604,294
5,604,295
string array in string.xml in Android
<p>I want to create a string array in string.xml in values folder for my android application. How to do this.. can anybody help..</p>
android
[4]
1,725,665
1,725,666
How to find first non-uppercase letter in the string using python
<p>I'm a python newbie but have programmed a while in other languages. I have a long string of DNA (lower case) and AA sequences (upper case). Further at the start of the file I have a protein name all in upper case. Thus my file looks like this.</p> <p>PROTEINNAMEatcgatcg... JFENVKDFDFLK</p> <p>I need to find the first non-uppercase letter in the string so I can then cut out the protein name. Thus, what I would want from the above is:</p> <p>atcgatcg... JFENVKDFDFLK</p> <p>I can do this with a loop but that seems like overkill and inefficient. Is there a simply python way to do it?</p> <p>I can get all the uppercase letters using re.findall("[A-Z]",mystring) but then I would need to do a comparison to see where the result differs from the original string.</p> <p>Thanks!</p>
python
[7]
4,022,107
4,022,108
stream_context_get_params() in PHP 5.2.6
<p>could you help me please with this problem: </p> <p>i need to use this <strong>function stream_context_get_params()</strong> but it is available only from <strong>PHP 5.3</strong> or bigger. Our server is <strong>PHP 5.2.6</strong> and gives the following error: *Fatal error: Call to undefined function stream_context_get_params()* </p> <p>I have searched the internet but there's nothing related with this </p> <p>Is there any similar function like this one for older versions or maybe there is a workaround? </p>
php
[2]
2,955,862
2,955,863
jQuery - radio buttons that add/remove a class to their labels
<p>I know this may sound too easy for many but I just can't figure this one out on my own, I don't get what I'm missing.</p> <p>I have a set of radio buttons grouped in pairs. Each pair corresponds to an opt-in / opt-out section.</p> <p>What I need is to toggle a class <code>.active</code> on the <code>&lt;label&gt;</code>.</p> <p><strong>Here's my basic HTML:</strong></p> <pre><code>&lt;td class="btn opt-in"&gt; &lt;label&gt; &lt;input type="radio" name="radio1" value="radio1"&gt; &lt;/label&gt; &lt;/td&gt; &lt;td class="btn opt-out"&gt; &lt;label&gt; &lt;input type="radio" name="radio1" value="radio2"&gt; &lt;/label&gt; &lt;/td&gt; </code></pre> <p><strong>Here's my JavaScript</strong> (it works partially):</p> <pre><code>$('input:radio').click(function() { if ($(this).is(':checked')) { $(this).parent().addClass('active'); } else { $(this).parent().removeClass('active'); }; }); </code></pre> <p>With the above script I'm able to add the class to the label just fine, but not remove/toggle it.</p> <p>Here's a <strong><a href="http://jsfiddle.net/rzea/NNkeQ/2/" rel="nofollow">Fiddle</a></strong> for reference.</p> <p>Any help is greatly appreciated.</p>
jquery
[5]
436,593
436,594
Can not unzip/decompress the file from assets in nexus
<p>Can not unzip/decompress the file from assets in nexus. But if the device is not a problem other than nexus. Just in nexus cannot unzip, approximately where the fault. below is the code:</p> <pre><code>try { final int BUFFER = 8192; ZipInputStream inputStream = new ZipInputStream(context .getAssets().open("data.zip")); ZipEntry entry = inputStream.getNextEntry(); while (entry != null) { String innerFileName = "/data/data/com.myapp/tesdata/html" + File.separator + entry.getName(); File innerFile = new File(innerFileName); if (entry.isDirectory()) { innerFile.mkdirs(); } else { FileOutputStream outputStream = new FileOutputStream( innerFileName); BufferedOutputStream bufferedOutputStream = new BufferedOutputStream( outputStream, BUFFER); int count = 0; byte[] data = new byte[BUFFER]; while ((count = inputStream.read(data, 0, BUFFER)) != -1) { bufferedOutputStream.write(data, 0, count); } bufferedOutputStream.flush(); bufferedOutputStream.close(); } inputStream.closeEntry(); entry = inputStream.getNextEntry(); } inputStream.close(); } catch (Exception e) { Log.d("MyLog", "Message: "+e.getMessage()); } </code></pre> <p>In Logcat MyLog:</p> <pre><code>Entry: Message: null </code></pre>
android
[4]
2,773,153
2,773,154
List formation in python
<p>I need to put 3 items in the list.</p> <ol> <li>state..eg(1,2)</li> <li>action...eg..west</li> <li>cost....5</li> </ol> <p><code>list=[(state,action,cost), (state,action,cost).........]</code></p> <p>how can i make it in a form of list. For a particular state , action and cost is there. Moreover, if i need only state from the list, i should be able to extract it from the list.same thing goes for action too.</p>
python
[7]
4,209,092
4,209,093
Randomize two arrays the same way, javascript
<p>I'm using javascript and trying to sync two arrays so that both arrays have the same index location.</p> <pre><code> var array1 = ["word1","word2","word3","word4","word5"]; var array2 = [1,2,3,4,5]; array2.sort(function(){ return Math.random() -.5}); </code></pre> <p>This scrambles array2 into something like [2,3,1,5,4]</p> <p>Now I need array1 to get the same order: <code>["word2", "word3", "word1", "word 5", "word4"]</code></p> <p>How can I do this? </p>
javascript
[3]
472,051
472,052
Detecting non-dictionary words in messages
<p>I need to check if the word is in the dictionary (correctly spelled) or not in dictionary (misspelled). Is there any bulit-in dictionary / spell checking function I can use to achieve this?</p>
android
[4]
4,525,917
4,525,918
Read li values and insert them in an array?
<p>I have a ul with id ul1. In the UL I have 3 li, each containing a textbox. How do I read each and every li of the ul to retrieve the values of the textbox in the li and put them in an array?</p>
jquery
[5]
5,897,264
5,897,265
newline question
<p>I want to detect a carriage return or a newline character when a user enters data into a textarea. What is the best way to handle this? I've tried str_replace with escape characters but carriage returns and newlines are not detected.</p> <hr> <p>OK, say I type the following into a textarea:</p> <pre><code>The summer was hot this year but next year is supposed to be cooler. </code></pre> <p>I want to detect the CRs. In this case, there is one.</p>
php
[2]
3,958,182
3,958,183
jQuery: how to detect form by name
<p>I have problem to add jQuery to some existing code, please help.</p> <p>We have the same form (same form name, same fields, same submit button, no id or class defined for the form) appeared couple of times on a page, now I need to validation the form with jQuery, without passing in the form object, can jQuery tell which form was submitted?</p> <p>Thanks everyone for your response, problem solved :-)</p>
jquery
[5]
762,334
762,335
shorthand variable assignment
<p>In java I'm trying to use shorthand variable assignment like below. Currently <code>owner</code> is assigned on a different line but I'd like to put it on the same line as below. This isn't working - is it not possible or is there another route?</p> <pre><code> if ((User owner = search.getOwner()) instanceof User &amp;&amp; owner.getId() != null) { searchQuery.append("owner_id = :ownerId AND "); queryMap.put("ownerId", owner.getId()); } </code></pre> <p>Thanks</p>
java
[1]
3,825,497
3,825,498
integrating 2 androids project into a third project
<p>I am having 2 android projects.Can anyone help in integrating both these project into a single one. Actually I am trying to operate both projects from a single page which contain an option in its user interface to run either of these projects(application).</p>
android
[4]