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,498,071
3,498,072
compare if with hebrew letter
<p>I write code that work only with english letters. when I ctry to do it with hebrew letter I get error.</p> <p>the code:</p> <pre><code>&lt;?php $idan="emr"; $firstletter = mb_substr($idan, 0, 1, 'UTF-8'); if ($firstletter=='e') echo "tov"; else echo "lo tove"; ?&gt; </code></pre> <p>work good. but the code:</p> <pre><code>&lt;?php $idan="אבהבה"; $firstletter = mb_substr($idan, 0, 1, 'UTF-8'); if ($firstletter=='א') echo "tov"; else echo "lo tove"; ?&gt; </code></pre> <p>not work, How I can to fix it?</p>
php
[2]
2,381,169
2,381,170
Pointers in javascript?
<p>Can we pass a reference of a variable that is immutable as argument in a function ? </p> <p>Example:</p> <pre><code>var x=0; function a(x) { x++; } a(x); alert(x);//Here i want to have 1 instead of 0 </code></pre>
javascript
[3]
1,008,568
1,008,569
Android - Parabolic motion
<p>I have a moving object in surface view it stat moving from fixed location.</p> <p>I need set to it to be move like parabolic way ..my object drawn like using x and y so I do</p> <p>not know using that thread how to calculate the X and y plz help?</p>
android
[4]
3,826,035
3,826,036
Installing .apk file on Emulator in Linux
<p>I'm trying to integrate the Zxing Bar code scanner into an application, but I need to install the bar code application on the emulator first. I already downloaded the .apk file. How do I install it on the emulator? I'm running Ububtu.</p>
android
[4]
1,632,077
1,632,078
Retrieve the list of alla jpg file of a directory
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/3202203/finding-a-file-with-a-specific-name-with-any-extension">Finding a file with a specific name with any extension</a> </p> </blockquote> <p>i've this code for put into an array all the files contained into a directory</p> <pre><code>$directory = "./"; $ourDirList = scandir($directory); $arraylistafiles=array(); foreach($ourDirList as $ourItem) { if (is_file($ourDir . $ourItem)) {$arraylistafiles[]=$ourItem;} } </code></pre> <p>but if i want to put only the file that have ".jpg" extension, what i can do? </p>
php
[2]
2,906,973
2,906,974
Servlet Security question about j_security_check, j_username and j_password
<p>I used jdbcRealm in my web application and it's working fine. I defined all constraints also in my web.xml. Like all pages of url pattern /Admin/* should be accessed by only admin. I have a login form with uses standard j_security_check, j_username and j_password.</p> <p>Now, when i type Admin/home.jsf it rightly redirects me login.jsf and there when i type the password i am redirected to home.jsf. This works alright but problem comes i directly go to login.jsf and then type password and username. This time it again redirects me to login.jsf. Is there any way through which i can specify which page to go when successful login is there? I need to specify different different pages for different roles. For Admin, it is /Admin/home.jsf for general users it is /General/home.jsf because login form is shared between different type of users. Where do i specify all these things?</p> <p>Secondly, i want to have a remember me checkbox at the end of login form. How do i do this? By default, it is submitted to j_security_check servlet and i have no control over its execution. Please help. This doesn't seem so hard but looks like i am missing something.</p>
java
[1]
3,603,350
3,603,351
Pause and Resume a For-Loop in C#
<p>hey guys, m working on a windows App in C#, i have a for-loop which does some updation in a loop, and i have 3 buttons on the form named "Stop,Pause,Resume". So the purpose is same as the buttons named.. any1 outthere know this how to do?</p> <p>Here is the Loop</p> <pre><code> private void btnCompleteAuto_Click(object sender, EventArgs e) { setGeneralValue(); for (int i = 1; i &lt;= autoGridView.Rows.Count - 1; i++) { if (SRP == "Pause") // this is wat i was thinking but it wont work { // it will go in end-less loop do // how to stop this loop on "Resume" button click'd { }while(SRP!="Resume") } car = false; try { MemberID = Convert.ToInt64(autoGridView.Rows[0].Cells["Member_ID"].Value); DispID = Convert.ToString(autoGridView.Rows[0].Cells["Disp_Id"].Value); Mobile = Convert.ToString(autoGridView.Rows[0].Cells["Mobile"].Value); DueDate = Convert.ToString(autoGridView.Rows[0].Cells["Due_Date"].Value); } catch (Exception) { MessageBox.Show("Row Not Found"); } AutoRecharge(network_name, pack_name, Mobile, Mobile, Convert.ToString(autoGridView.Rows[0].Cells["Rck_Amt"].Value), vendor_id, vendor_pwd, pack_id, oxinetwork_id); autoGridView.Rows.RemoveAt(0); } } </code></pre> <p>Here are the 3 button events in which m setting a variable</p> <pre><code> private void btnPause_Click(object sender, EventArgs e) { SRP = "Pause"; } private void btnStop_Click(object sender, EventArgs e) { SRP = "Stop"; autoGridView.DataSource = ""; } private void btnResume_Click(object sender, EventArgs e) { SRP = "Resume"; } </code></pre>
c#
[0]
3,011,233
3,011,234
capture mousedown event and get clientX and clientY in Mozilla
<pre><code>if (browserName == "Firefox") { if (window.captureEvents(Event.MOUSEDOWN)) { window.mousedown = load; } } function load(e) { alert(e.clientX); } </code></pre> <p>I want to mousedown on canvas and get <code>clientX</code> and <code>clientY</code>. I'm doing it the above way but not getting it.</p>
javascript
[3]
5,942,988
5,942,989
passing parameters from one php to multiple php
<p>.I have three php pages:</p> <p>page1.php page2.php page3.php</p> <p>on page1.php i have this code:</p> <pre><code>&lt;form id="try" method="post" action="page2.php"&gt; Batch: &lt;input id="batch" name="batch" type="text"/&gt;&lt;br /&gt; Dept: &lt;input id="dept" name="dept" type="text"&gt;&lt;br /&gt; &lt;input type="submit" /&gt; &lt;/form&gt; </code></pre> <p>on page2.php i am able to use the values inserted on page1.php by simply calling them using <code>$_POST['batch']; and $_POST['dept'];</code></p> <p>but what i want to do next is to pass the values of batch and dept from page2.php to page3.php. or maybe from page1.php to page2.php since i think it's just the same.</p> <p>.Help pls! Thanks in adv</p> <p>@kjy112 - i'm confused, since i am using </p> <pre><code>&lt;form method="post"&gt; </code></pre> <p>should i be starting my session on page2.php by using the following:</p> <pre><code>session_start(); $_SESSION['batch'] = $_POST['batch']; $_SESSION['dept'] = $_POST['dept']; </code></pre> <p>and then use</p> <pre><code>session_start(); $batch = $_SESSION['batch']; </code></pre> <p>to use it on page3.php?</p>
php
[2]
4,723,101
4,723,102
MediaPlayer video not showing
<p>I have this big problem with playing video on my app. I have this game and wanted to show some videos somewhere but, in the best case I can hear the sound but not see the video.</p> <p>this is the holder</p> <pre><code> public void surfaceCreated(SurfaceHolder holder) { level.playerholder = holder; gameLoopThread.setRunning(true); renderLoopThread.setRunning(true); gameLoopThread.start(); renderLoopThread.start(); } </code></pre> <p>this is the creation of the mediaplayer and should show the video</p> <pre><code>while(!playerholder.isCreating()); MediaPlayer mediaPlayer = new MediaPlayer(); mediaPlayer.setDisplay(playerholder); switch(startVideo){ case 1: try { mediaPlayer.setDataSource(context,Uri.parse("android.resource://com.getfun.treevolve/raw/getfunvideo")); mediaPlayer.prepare(); } catch (IllegalArgumentException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (SecurityException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (IllegalStateException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } break; } Log.d("player", "Sec: " + Integer.toString(mediaPlayer.getDuration())); Log.d("player", "Video width: " + Integer.toString(mediaPlayer.getVideoWidth())); mediaPlayer.start(); </code></pre> <p>With this settings my log shows only 0. Like the video is wrong. If in the second line I delete the holder</p> <pre><code> mediaPlayer.setDisplay(playerholder); </code></pre> <p>is working, all the info in the log are showing correctly but, I hear the audio but don't see anything.</p> <p>Thank you for the help, I really need this. =)</p>
android
[4]
1,784,981
1,784,982
ASP.Net OnClick vs Function() Handles buttonName.Click
<p>What is the difference between using the OnClick attribute of an ASP.Net Button:</p> <p><code>&lt;asp:Button ID="btn" runat="server" Text="New" OnClick="enterFunctionHere" /&gt;</code></p> <p>vs. </p> <p>using the event directly in the function:</p> <p><code>Sub addNew() Handles btn.Click</code></p> <p>Thanks!</p> <p><strong>UPDATE</strong></p> <p>If I can do both in VB, which is better? Are they equal?</p>
asp.net
[9]
435,454
435,455
Сompound string from multiple input fields
<p>I have a 3 input fields. 2 for values and one fild for result.</p> <pre><code> &lt;input type="text" value="" id="name"&gt; &lt;input type="text" value="" id="surn"&gt; &lt;input type="text" value="" id="result"&gt; </code></pre> <p>In the results of the first two zancheniya fields must be joined. For example</p> <p>1 - John</p> <p>2 - Smith</p> <p>3 (result) John Smith</p> <p>I have solution for one field <a href="http://jsfiddle.net/LvZdL/1/" rel="nofollow">http://jsfiddle.net/LvZdL/1/</a></p> <pre><code> $("input#name").keyup(function () { var name = $(this).val(); $("input#result").val(name); }).keyup(); </code></pre>
jquery
[5]
5,426,162
5,426,163
Jquery disabling auto window scrolling
<p>I've created a simply Jquery image transition viewer, and every time a new photo is loaded, the window automatically scrolls up to the top of the new image that just loaded. I am trying to stop this, so that the transition does not interrupt wherever the user may be on the page. </p> <p>Here is my code so far:</p> <pre><code>$(document).ready(function() { var slideShow = function() { current_img = $("#current_img"); // &lt;img&gt; element with src to be changed height_width = 'width="100%" height="100%"'; photos = new Array('images/home_s1.png','images/home_s2.png', 'images/home_s3.png'); setTimeout(function() { current_img.fadeOut('fast', function() { current_img.attr('src', photos[0]); current_img.fadeIn('slow'); }); }, 0); setTimeout(function() { current_img.fadeOut('fast', function() { current_img.attr('src', photos[1]); current_img.fadeIn('slow'); }); }, 5000); setTimeout(function() { current_img.fadeOut('fast', function() { current_img.attr('src', photos[2]); current_img.fadeIn('slow'); }); }, 10000); setTimeout(function() { slideShow(); }, 15000); } $("img").ready(slideShow); }); </code></pre> <p>I've tried multiple different ways of manipulating the preventDefault() function, and I have also tried different variations of loading the image (i.e. loading into html() instead of img.attr('src')), but no luck... Any suggestions on the most efficient way of achieving this?</p>
jquery
[5]
2,258,345
2,258,346
The method length() is undefined for the type JSONArray
<p>Eclipse always gives me this compilation error when I try to get the length of a JSONArray:</p> <blockquote> <p>the method length() is undefined for the type JSONArray</p> </blockquote> <p>Here is the code:</p> <pre><code>import org.springframework.context.annotation.Scope; import java.net.*; import java.io.*; import net.sf.json.JSONArray; import net.sf.json.JSONObject; import net.sf.json.JSONSerializer; import javax.inject.Named; @Named("search") @Scope("request") public class Search { private String query; private String result; private int num; public String getQuery() { return query; } public void setQuery(String query) { this.query = query; } public String getResult() { return this.result; } public void setResult(String result) { this.result = result; } public int getNum() { return this.num; } public void setNum(int num) { this.num = num; } public String send() { try { //SEND REQUEST TO SOLR SERVER URL url = new URL("http://localhost:8983/solr/select/?q="+this.query +"&amp;version=2.2&amp;start=0&amp;rows=100&amp;indent=on&amp;wt=json"); BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream())); String str; while ((str = in.readLine()) != null) { this.result = this.result+str; } in.close(); //CONVERT RESULT TO OBJECT this.result=this.result.substring(4); JSONObject json = (JSONObject) JSONSerializer.toJSON(this.result); JSONArray results = new JSONArray(); json = json.getJSONObject("response"); this.num = json.getInt("numFound"); results = json.getJSONArray("docs"); int num = results.length(); </code></pre> <p>I have no idea why this error is popping up. How is this caused and how can I solve it?</p>
java
[1]
269,511
269,512
return value from a function running in separate thread
<p>I have this code that allows to execute functions in a separate thread if "Asynch" annotation is present on them. Everything works fine, except for the day when I realized I also have to handle return value for some new functions that I've just added. I could use handlers and message-passing for this, but, due to already built project structure(which is huge and working fine), I can't change the existing functions to work with message passing. </p> <p>Here's the code:</p> <pre><code>/** * Defining the Asynch interface */ @Retention(RetentionPolicy.RUNTIME) public @interface Asynch {} /** * Implementation of the Asynch interface. Every method in our controllers * goes through this interceptor. If the Asynch annotation is present, * this implementation invokes a new Thread to execute the method. Simple! */ public class AsynchInterceptor implements MethodInterceptor { public Object invoke(final MethodInvocation invocation) throws Throwable { Method method = invocation.getMethod(); Annotation[] declaredAnnotations = method.getDeclaredAnnotations(); if(declaredAnnotations != null &amp;&amp; declaredAnnotations.length &gt; 0) { for (Annotation annotation : declaredAnnotations) { if(annotation instanceof Asynch) { //start the requested task in a new thread and immediately //return back control to the caller new Thread(invocation.getMethod().getName()) { public void execute() { invocation.proceed(); } }.start(); return null; } } } return invocation.proceed(); } } </code></pre> <p>Now, how can i convert it so that if its something as:</p> <pre><code>@Asynch public MyClass getFeedback(int clientId){ } MyClass mResult = getFeedback(12345); </code></pre> <p>"mResult" gets updated with the returned value?</p> <p>Thanx in advance...</p>
java
[1]
208,975
208,976
how to avoid 'session break' in two panels
<p>i am a student and i am new in php</p> <p>i am working on my project</p> <p>i have two panels in my website (localhost) one is user other is admin</p> <p>in both panels i hace created sessions on all pages</p> <p>on user panel:</p> <pre><code>session_start(); if(!isset($_SESSION['user'])) header("Location: index.php"); </code></pre> <p>on admin panel:</p> <pre><code>session_start(); if(!isset($_SESSION['username'])) { header("Location: login.php?e=please+login+first"); } </code></pre> <p>now i have opened both panels and problem is that if i logout from one panel then other panels also logout .</p> <p>forexample if i logout in user panel as a user then my admin panel session automatically redirect page to login.php when i refresh admin page</p> <p>is there any way to avoid this or how to avoid this.. please help me. i shall be thankful</p> <pre><code>here is my logout code for admin side &lt;?php session_start(); session_destroy(); header("Location: login.php?e=Logout+successfully"); ?&gt; for user side &lt;?php session_start(); session_destroy(); header("Location: index.php?l=Logout+successfully"); } ?&gt; </code></pre>
php
[2]
555,477
555,478
"or die()" in Python
<p>Is anyone using anything like this in Python:</p> <pre><code>def die(error_message): raise Exception(error_message) ... check_something() or die('Incorrect data') </code></pre> <p>I think this kind of style is used in PHP and Perl.</p> <p>Do you find any (dis)advantages in this [style]?</p>
python
[7]
2,770,465
2,770,466
Using global variable as default parameter
<p><strong>a.py</strong></p> <pre><code>#!c:/Python27/python.exe -u from connection import Connection import globals globals.server_ip = '192.168.0.1' connection = Connection() </code></pre> <p><strong>globals.py</strong></p> <pre><code>#!c:/Python27/python.exe -u server_ip = '127.0.0.1' </code></pre> <p><strong>connection.py</strong></p> <pre><code>import globals class Connection: def __init__(self, server_ip = globals.server_ip): print 'Connection is ' + server_ip + '\n' </code></pre> <p>I was expecting I will be getting <code>Connection is 192.168.0.1</code> being printed. But, instead, <code>Connection is 127.0.0.1</code> is being printed.</p> <p>Unless I try to construct the connection by passing in the parameter explicitly (which is not something I wish to, as I am reluctant to make change any more on Connection with 0 parameter)</p> <p><code>connection = Connection(globals.server_ip)</code></p> <p>Why is this so? Is there any other techniques I can apply?</p>
python
[7]
4,677,933
4,677,934
Duplicate methods in java.io.Console?
<p>In <a href="http://docs.oracle.com/javase/7/docs/api/java/io/Console.html" rel="nofollow"><code>java.io.Console</code></a>, there are two methods, <a href="http://docs.oracle.com/javase/7/docs/api/java/io/Console.html#printf%28java.lang.String,%20java.lang.Object...%29" rel="nofollow"><code>printf</code></a> and <a href="http://docs.oracle.com/javase/7/docs/api/java/io/Console.html#format%28java.lang.String,%20java.lang.Object...%29" rel="nofollow"><code>format</code></a>, which appear to be identical. In the API it says</p> <blockquote> <p>An invocation of this method of the form <code>con.printf(format, args)</code> behaves in exactly the same way as the invocation of <code>con.format(format, args)</code></p> </blockquote> <p>So why have two methods? Is there a case where one is preferred?</p> <p>EDIT: They've done this in java.io.PrintStream as well in Java 5 </p>
java
[1]
5,849,493
5,849,494
Why isnt the jquery anchor tag scroll working?
<p>Im trying to use some jquery to scroll some content on a portfolio gallery. The code im using i found on another site and allows the user to click the yellow arrows to scroll each project one at at time with anchor points however mine isn't allowing me to do that at the moment and im not sure why?</p> <p>I've set up a JS Fiddle here <a href="http://jsfiddle.net/b5X5w/2/" rel="nofollow">http://jsfiddle.net/b5X5w/2/</a></p> <p>thanks</p>
jquery
[5]
1,845,260
1,845,261
jquery iterator function parameters
<p>How can I pass a parameter to a jquery iterator function (or whatever they're called), like:</p> <pre><code> var states = new Array(); states.push(true); $(children).each(function(states) { if(this.depth&gt;states.length) { states.push(this.collapsed); } else if (this.depth&lt;states.length) { states.pop(); } var collapsed=states[states.length-1]; } ); </code></pre> <p>The "states" parameter arrives either as an int or a boolean, never an array. Suggestions? I'd prefer not to declare states as global. (The code above resides inside of a method).</p>
jquery
[5]
5,455,519
5,455,520
Separate the digit in an Integer (User-Input)
<p>How do I enter a digit like '23423' and output it like '2 3 4 2 3'? And how do I make it so that user cannot enter less or more than 5-digits? (Your help would be appreciated. I just need hints from you guys since I'm learning Java. Looking forward to learn something new.)</p> <p>This is what I have so far:</p> <pre><code> Scanner input = new Scanner(System.in); int value1, value2, value3, value4, value5; System.out.print("Enter a number: "); value1 = input.nextInt(); System.out.print("Enter a number: "); value2 = input.nextInt(); System.out.print("Enter a number: "); value3 = input.nextInt(); System.out.print("Enter a number: "); value4 = input.nextInt(); System.out.print("Enter a number: "); value5 = input.nextInt(); System.out.printf(" %d " + " %d " + " %d " + " %d " + " %d\n ", value1, value2, value3, value4, value5); </code></pre>
java
[1]
633,778
633,779
iphone - comparing two times
<p>how do i , given two times in HH:mm:ss format compare then and determine which is the later time. </p> <p>12:00:00 &amp; 14:00:00 </p> <p>how do i determine that 14:00:00 is the later time </p>
iphone
[8]
2,360,583
2,360,584
How to align an 90 deg rotated label perfectly with the pixels?
<p>When rotating a label, the text is rendered very ugly. Is there an convenient way to get the label aligned with the pixels? Maybe there is some way of rounding the transform of the view, so that it isn't misaligned?</p>
iphone
[8]
3,625,521
3,625,522
Javascript get element that was clicked based on ClassName
<p>First, I would have created this example in JSFiddle but they are in read-only mode.</p> <p>I would like to get the specific element that was clicked based on a class.</p> <pre><code>var button = document.getElementsByClassName("mybutton"); button.onclick = function() { //how do I reference the specific button that was clicked? }; </code></pre> <p>&nbsp;</p> <pre><code>&lt;button class="myclass"&gt;Button 1&lt;/button&gt; &lt;button class="myclass"&gt;Button 2&lt;/button&gt; </code></pre> <p>No jQuery answers please; that is not an option here.</p>
javascript
[3]
1,418,109
1,418,110
Loop and comparing each element of array?
<p>I am trying to compare each element from two array <code>$min</code> and <code>$max</code></p> <pre><code>$test = false; $min = array(2,3,3,55,556); $max = array(22,32,4,56,557); foreach($min as $key=&gt;$val){ foreach($max as $k=&gt;$v){ if($val &gt;= $v){ $test=true; break; } } } if($test){ echo "A NOT GREATER THAN or EQUAL B"; }else{ echo "YOU CAN SAVE NOW"; } </code></pre> <p>What I am wrong?because I got the message here</p> <pre><code> A NOT GREATER THAN or EQUAL B </code></pre> <p>thanks</p>
php
[2]
4,553,905
4,553,906
No Dumpbin.exe
<p>I do not see dumbin.exe on my sysytem . I have Visual Studio 2005 on my system . When I type dumpbin on command line , it says unrecognizable command .</p> <p>Does not it come ( by default ) with Visual Studio , or do I have to explicitly add this tool . </p>
c++
[6]
4,348,460
4,348,461
What is Operator overloading? Is operator overloading a specific feature to C++ and not available in Java
<p>Please explain in detail with examples. Thank you</p>
c++
[6]
4,306,635
4,306,636
Python: How to switch off scaning of the lib directories at start
<p>I have installed my own python with 10000 additional modules. Both the python and the modules are located on a small NFS share. When I start the python it scans all its library directories and looks for available modules. It takes several seconds.</p> <p>How I can explicitly switch this scanning process off?</p>
python
[7]
4,702,169
4,702,170
Can I call a funcion when I stop to "resize" the window?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/667426/javascript-resize-event-firing-multiple-times-while-dragging-the-resize-handle">javascript resize event firing multiple times while dragging the resize handle</a> </p> </blockquote> <p>Tried :</p> <pre><code>$(window).bind('load resize', function (e) { console.log("resized"); }); </code></pre> <p>but it wrote "resized" for every small movement of the window. Can I call a function (In this example, that console.log()) only when I finish (I stop) to resize the window?</p> <p>Thank you!</p>
jquery
[5]
3,788,933
3,788,934
Code conversion from C to C#
<p>I have to convert code from c to c#. I want to know in how many ways I can do that. Are there any tools which will convert code from c to c# without affecting the functionality.</p> <p>Thanks &amp; Regards,</p>
c#
[0]
2,723,857
2,723,858
Difference between getmypid() and posix_getpid()
<p>What's the difference between the getmypid() and the posix_getpid() functions?</p> <p>I turned to getmypid() because my script has to run both on Windows and on Linux.</p>
php
[2]
2,960,728
2,960,729
How can obtain age by birth date
<p>I want get the exact age of the following date in var <code>$birth_date</code> by php, How is it?</p> <p><code>$birth_date = 2011/12/16;</code></p> <p>$birth_date => For example, this is my birth date.</p> <p>For example output from my birth date is: <code>0 Year, 0 Month, 1 Day</code></p>
php
[2]
5,916,190
5,916,191
applying force to more than one object
<p>hi i have been working with chai-3d and opengl for creating a simulation for haptic device . i have drawn a sphere which is positioned at center and another small spheres positioned around the center sphere, for each 15deg a sphere will be drawn based on the center sphere.below piece of code will draw center sphere.</p> <pre><code>cShapeSphere *sphere; cShapeSphere* sphere2; void sphere(void) { float r1=0.020; float a=0.0; float b=0.0; float r2=r1/6; float th=15; double pi=3.14159265; sphere =new cShapeSphere(r1); world-&gt;addChild(sphere); sphere-&gt;setPos(0,a,b); //this will draw small sphere around the main sphere for(int j=1;j&lt;=24;j++) { sphere2 =new cShapeSphere(r2); world-&gt;addChild(sphere2); sphere2-&gt;setPos(0,a+(r1+r2)*cos(th*j*pi/180),b+(r1+r2)*sin(th*j*pi/180)); //this were i apply the force double strength = pow((sphere2-&gt;getRadius() - length) * 8000,2); force = (c_pos - spos) * strength; //the calculated force is sent to haptic device hapticDevice-&gt;setForce(force); } } </code></pre> <p>when i tried to apply the force for all the smaller spheres,the force is detected only on the first smaller sphere positioned at 15 degree.cant apply force for the spheres positioned at 30 degrees to 360 degrees.the calculated force is sent to the haptice device.the problem is with the spheres,were 24 smaller spheres are drawn around the center sphere.the variable that i used to draw the 24 spheres is sphere2.let us consider iam drawing the spheres by giving different variable name say sphere 1 to 24,there i can apply the force without any problem because i use different variables but if i use same name for drawing all the spheres then the force is applied only at the first iteration...the force is not applied for other 23 iterations out of 24.i have to iterate the force along with the sphere position.</p>
c++
[6]
5,067,323
5,067,324
Object Oriented Programming in Javascript
<p>Consider an OOP model. I wanted to implement, </p> <pre><code>funct1( arg ).subfunct1( arg ); ( </code></pre> <p>Of course like jQuery. where you have <code>$( arg ).subfn( arg )</code></p> <p>I have done it successfully for one subfunction. BUT,</p> <pre><code>funct1( arg ).subfunct1( arg ); // ==&gt; works fine. funct1( arg ).subfunct1( arg ).subfunct( arg ); // ==&gt; doesnt work. </code></pre> <p>Source is:</p> <pre><code>var funct1=function() { var dummy=new Object(); dummy.subfunct1=bla bla; dummy.subfunct2=bla bla; return dummy; } </code></pre> <p>Can you say any remedies.</p>
javascript
[3]
1,844,382
1,844,383
What's the term for this? [found, fluent interface]
<p>What's the term for this design?</p> <pre><code>object.method1().method2().method3() </code></pre> <p>..when all methods return *this?</p> <p>I found the term for this a while ago, but lost it meanwhile. I have no clue how to search for this on google :) Also if anyone can think of a better title for the question, feel free to change it.</p> <p>Thanks</p> <p><strong>Update-Gishu</strong>: After reading about it, I feel that your question is misleading w.r.t. code snippet provided.. (Feel free to rollback)</p> <p><em>Method Chaining</em></p> <pre><code>object.method1().method2().method3() </code></pre> <p><em>Fluent Interfaces</em></p> <pre><code>private void makeFluent(Customer customer) { customer.newOrder() .with(6, "TAL") .with(5, "HPK").skippable() .with(3, "LGV") .priorityRush(); } </code></pre>
c++
[6]
5,163,120
5,163,121
Printing from Tkinter or PMW intrerface
<p>I have created an interface in both Python Mega Widgets and Tkinter that is an interface to a SQlite3 database. The query results are returned as a list and disiplayed in a memo field located on the main frame of the display.</p> <p>Can I create a small function that will be launched from a button that will <strong>print</strong> the contents of the memo field?</p> <p>something like:</p> <pre><code>command = printMemo #argument within the print button #the print function I am looking for in pseudocode def printMemo(memo): print memo </code></pre>
python
[7]
2,992,816
2,992,817
Problem with implicitly conversion of string
<p>I have a object 'currentVersion' of type Data and string variable of 'version',i need to assign what ever things coming 'version' to 'currentVersion' Code is like this</p> <pre><code> private static DataVersion currentVersion = new DataVersion(); string version = this_event.variableData[1].atr_value; and in internal layers public SPD_variableData[] variableData; and /// &lt;summary&gt; /// Definition of variable data for events. /// &lt;/summary&gt; public struct SPD_variableData { /// &lt;summary&gt; /// attribute name /// &lt;/summary&gt; public string attribute; /// &lt;summary&gt; /// attribute value /// &lt;/summary&gt; public string atr_value; } </code></pre> <p>but when i did currentVersion = version ; i am getting error like this "Error 1 Cannot implicitly convert type 'string' to 'Safe.Model.Data' " if that is the case how i can assign values coming on version to currentVersion</p>
c#
[0]
2,443,826
2,443,827
Get content of a file, throws "host name may be null"
<p>I'm having a trouble getting the content of a file located at a address similar to "http:///127.0.0.1:1935/app/unique_id/file.txt". The exception states that the host name may be null. I think the problem is due to the port.</p> <p>How do I get the content of the file?</p> <pre><code> final HttpGet httpGet = new HttpGet(url); HttpParams httpParameters = new BasicHttpParams(); HttpConnectionParams.setConnectionTimeout(httpParameters, timeoutConnection); HttpConnectionParams.setSoTimeout(httpParameters, timeoutSocket); final DefaultHttpClient httpClient = new DefaultHttpClient(httpParameters); InputStream inputStream = timedCall(new Callable&lt;InputStream&gt;() { public InputStream call() throws Exception { HttpResponse response = httpClient.execute(httpGet); return response.getEntity().getContent(); }; }, 10, TimeUnit.SECONDS); return inputStream; </code></pre>
android
[4]
122,019
122,020
Android: how to cancel a request of Location update with intent?
<p>I registered a PendingIntent to requestLocationUpdates(provider, minTime, minDistance, PendingIntent). But when my broadcast receiver receives this intend, how do I remove this request with removeUpdates(PendingIntent)? The receiver doesn't hold a reference to the original PendingIntent.</p>
android
[4]
3,944,179
3,944,180
How do I force a ViewGroup to draw off screen?
<p>I have several LinearLayouts that get filled with downloaded images or text within a ScrollView. The LinearLayouts have a LayoutAnimation applied to them, so each one "slides" into place when drawn. Is there a way to force the offscreen LinearLayouts to draw so that by the time the user scrolls to them, the animation has already completed? I've tried measuring each view like so: (<strong>container</strong> is the ViewGroup)</p> <pre><code>int measuredWidth = View.MeasureSpec.makeMeasureSpec(LayoutParams.FILL_PARENT, View.MeasureSpec.AT_MOST); int measuredHeight = View.MeasureSpec.makeMeasureSpec(LayoutParams.WRAP_CONTENT, View.MeasureSpec.UNSPECIFIED); container.measure(measuredWidth, measuredHeight); container.layout(0, 0, container.getMeasuredWidth(), container.getMeasuredHeight()); container.requestLayout(); </code></pre> <p>But they still won't draw until they appear on screen during scrolling (which normally is fine but the animation makes it.. er, not fine)</p>
android
[4]
5,463,284
5,463,285
String to date with no format specified
<p>I want to convert a string into a date, this is simple. But what I'd like to do it without knowing the date format.</p> <p>Here is a situation: say I have 100 dates and all are in the same format but I'd like to write a Java program to find out this format for me. The result of this program should give me a list of all the possible formats.</p> <p>For example:</p> <pre><code> 06-06-2006 06-06-2009 ... 06-13-2001 &lt;- 99th record </code></pre> <p>the result of this will give me date format can be <code>mm-dd-yyyy</code></p> <p>If the 99<sup>th</sup> record also was <code>06-06-2006</code> the result should be <code>mm-dd-yyyy</code> and <code>dd-mm-yyyy</code>.</p> <p>Can someone please help me with an example?</p>
java
[1]
14,100
14,101
create new array from a multidimensional array
<p>I have this multidimensional array: </p> <pre><code>Array ( [0] =&gt; Array ( [id] =&gt; 1 [list_name] =&gt; List_Red ) [1] =&gt; Array ( [id] =&gt; 2 [list_name] =&gt; List_Blue ) ) </code></pre> <p>...and i would like to create a new array containing only the [id]'s from it.</p> <p>I would appreciate it alot if you guys could help me with that ^^</p> <p>Thanks in advance</p>
php
[2]
2,898,527
2,898,528
How do I identify or know which control is being referenced in a method?
<p>In my specific case, how do I identify or know which UITextField is being referenced in shouldChangeCharactersInRange method?</p> <p>I know the parameter (UITextField*)textField contains the object being referenced, but how do I compare to identify which one it is?</p>
iphone
[8]
5,394,643
5,394,644
Read a particular line in a string?
<p>Here is my string line:</p> <pre><code>string conSTR = "Data Source=(local);Initial Catalog=MyDB;User ID=sa"; </code></pre> <p>I just want to get the string <code>"(local)"</code>, and <code>"MyDb"</code> and <code>"sa"</code> word anybody can suggest how to do it in C#.</p>
c#
[0]
5,114,185
5,114,186
OVERLOADING OPERATORS = error
<p>I am trying to use overloading concept to equate 3 objects <code>c1</code>, <code>c2</code>, <code>c3</code>. But it is giving me an error </p> <pre><code>error: no match for 'operator=' in 'c3 = c2. circle::operator=(((circle&amp;)(&amp; c1)))' </code></pre> <p>What's the reason behind it how do I rectify it??</p> <pre><code>#include&lt;iostream&gt; using namespace std; class circle { private: int radius; float x,y; public: circle() {} circle(int rr,float xx,float yy) { radius=rr; x=xx; y=yy; } circle&amp; operator=(const circle&amp; c) { cout&lt;&lt;endl&lt;&lt;"assignment operator invoked"; radius=c.radius; x=c.x; y=c.y; return *this; } void showdata() { cout&lt;&lt;endl&lt;&lt;"\n radius="&lt;&lt;radius; cout&lt;&lt;endl&lt;&lt;"x coordinate="&lt;&lt;x; cout&lt;&lt;endl&lt;&lt;"y coordinate="&lt;&lt;y&lt;&lt;endl; } }; int main() { circle c1 (10,2.5,2.5); circle c2,c3; c3=c2=c1; c1.showdata(); c2.showdata(); c3.showdata(); return 0; } </code></pre> <p>so this overloaded operator will be called two times.. First for c2=c1 and then for c3=c2 but how will compiler compare it with overloaded operator definition??</p>
c++
[6]
1,236,070
1,236,071
post method in javascript
<p>How i can pass the value from javascript post method from one page (home.aspx) to another page(post.aspx) which needs to open in new window using window.open method .? My code below:this javascript function called in button click event.</p> <pre><code>function postwith () { var myForm = document.createElement("form"); myForm.method="post" ; myForm.action = post.aspx ; var myInput = document.createElement("input") ; myInput.setAttribute("name", 'user'); myForm.appendChild(myInput) ; document.body.appendChild(myForm) ; myForm.submit() ; document.body.removeChild(myForm) ; } &lt;asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="postwith();"/&gt; </code></pre> <p>I want access the value (user) in page load event of post.aspx pge and this page should open in new window.</p>
javascript
[3]
2,562,950
2,562,951
Why is this code Seg_Faulting?
<p>I can't understand why this code would segmentation fault. Any help out there? This is for a riddle in a book, not for a homework assignment. </p> <p>Code : <a href="http://pastebin.com/WvWkckzX" rel="nofollow">http://pastebin.com/WvWkckzX</a></p> <p>Input : <a href="http://pastebin.com/yvHXquuf" rel="nofollow">http://pastebin.com/yvHXquuf</a></p> <p>Prompt : <a href="http://pastebin.com/dmmyG2DY" rel="nofollow">http://pastebin.com/dmmyG2DY</a></p> <p>Input: The first line contains the number of test cases T. T test cases follow. The first line of each test case contains N and M. The next N lines describe the cities in Byteland. The ith line contains a letter 'A' or 'B' signifying the army division located in city i and the cost ci of defeating that army. The next M lines describe the roads in the city. The ith line contains xi and yi, the numbers of the cities connected by a road.</p> <p>Output: Output T lines, one corresponding to each test case containing the cheapest cost of accomplishing your goal.</p> <p>Sample Input:</p> <pre><code>1 3 3 A 1 A 1 B 10 1 2 1 3 2 3 </code></pre> <p>Sample Output:</p> <pre><code>2 </code></pre> <p>City 1 (A-1) connects to city 2 (A-1) and city 3 (B-10). To attack city 3 will cost 10, while to simply attack cities 1 and 2 will cost only 2.</p> <p>GDB tells me that it seg faults in 'cost_testCase'</p>
c++
[6]
5,820,622
5,820,623
How to check whether a default browser is opened in the operating system (Java)?
<p>I am newbie here. During my work, I faced an interesting problem. I need to:</p> <p> <ul> <li>check whether a default html browser is opened; <li>check whether the browser is minimized/maximized (simply, a window's state); <li>get an url address typed in the browser. </ul> </p> <p><p>If any of these conditions is not met, I have to open the browser in a maximized view with a desired url address.</p> <p>I primarily wanted to do all this in Java, but it came to my mind that I should employ many techniques/technologies and combine them appropriately to complete the functionality. But, which ones? That's the problem. </p><p>I just recalled Windows API, but I'm not sure if it is of any help... Some users on another forum suggested that I should consider JNI (no experience at all)... I only know how to open a default browser (e.g. with use of the 'browse(URI uri)' method of the 'java.awt.Desktop' class) - that's too little to be proud of. </p>Please give me some hints, maybe links to reasonable discussions, I would greatly appreciate any suggestions how to approach the problem. </p>
java
[1]
2,734,190
2,734,191
issue with Javascript image changer
<p>I have a script running on my page to change the images. I want to repeat it 6 times to use in other places on the same page, but it wont work when I repeat it.</p> <pre><code> var delay = 2000 //set delay in miliseconds var curindex = 0 var randomimages = new Array() randomimages[0] = "hhh200.jpg" randomimages[1] = "ray200.jpg" var preload = new Array() for (n = 0; n &lt; randomimages.length; n++) { preload[n] = new Image() preload[n].src = randomimages[n] } document.write('&lt;img name="defaultimage" src="' + randomimages[Math.floor(Math.random() * (randomimages.length))] + '"&gt;') function rotateimage() { if (curindex == (tempindex = Math.floor(Math.random() * (randomimages.length)))) { curindex = curindex == 0 ? 1 : curindex - 1 } else curindex = tempindex document.images.defaultimage.src = randomimages[curindex] } setInterval("rotateimage()", delay) </code></pre> <p>Can anyone see why it's not working?</p>
javascript
[3]
918,456
918,457
Access violation writing location 0xaaaaaaaa
<p>This is my current code of the class Score in the <code>Score.h</code> file:- </p> <pre><code>class Score { protected: long m_Scores; long m_HighScore; //private: public: Score(); ~Score(); void Init(); void Update(float deltaMS); void Render(); void Release(); void SetScore(long sc){ m_Scores=sc; } long GetScore(){ return m_Scores; } void SetHighScore(long sc){ m_HighScore=sc; } long GetHighScore(){ return m_HighScore; } void AddScore(int add); }; </code></pre> <p>I am getting the following error whenever I try to access m_Scores in the class itself.</p> <pre><code>Access violation writing location 0xaaaaaaaa. </code></pre> <p>The <code>SetScore()</code> method can't be run due to this. I know I am doing something silly, but couldn't figure it out. Can you please help me out.</p>
c++
[6]
1,810,231
1,810,232
Is there a way to return/print list item without quotes or brackets?
<p>Sorry if this is already mentioned somewhere(I couldn't find it).</p> <p>I basically want to list an item from a list but its including quotes and brackets(which I don't want). Here's my data:</p> <pre><code>inputData = {'red':3, 'blue':1, 'green':2, 'organge':5} </code></pre> <p>Here's my class to find items either based on key or value.</p> <pre><code>class Lookup(dict): """ a dictionary which can lookup value by key, or keys by value """ def __init__(self, items=[]): """items can be a list of pair_lists or a dictionary""" dict.__init__(self, items) def get_key(self, value): """find the key(s) as a list given a value""" return [item[0] for item in self.items() if item[1] == value] def get_value(self, key): """find the value given a key""" return self[key] </code></pre> <p>it works fine except for the brackets.</p> <pre><code>print Lookup().get_key(2) # ['blue'] but I want it to just output blue </code></pre> <p>I know I can do this via replacing the bracket/quotes( <code>LookupVariable.replace("'", "")</code> ) but I was wondering if there was a more pythonic way of doing this.</p> <p>Thanks.</p>
python
[7]
5,579,849
5,579,850
for loop in php - list ul li tags
<p>I need to find out how to list ul navigation, maybe in a <code>for</code> loop? Each ul have different classes (there is max 3 ul)</p> <p>first ul class named "first", "center", and "last" </p> <p>I need some samples to get started. </p> <p>like: </p> <pre><code> for($x = 1; $x &lt; 3; $x++){ //html code } &lt;ul class="first"&gt; &lt;li class="first-child"&gt; &lt;ul&gt; &lt;li&gt; &lt;div class="image"&gt; // image goes here &lt;/div&gt; &lt;div class="info"&gt; // data &lt;/div&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; // next loop would look like: &lt;ul class="center"&gt; &lt;li class="first-child"&gt; &lt;ul&gt; &lt;li&gt; &lt;div class="image"&gt; // image goes here &lt;/div&gt; &lt;div class="info"&gt; // data &lt;/div&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; // and last &lt;ul class="last"&gt; &lt;li class="first-child"&gt; &lt;ul&gt; &lt;li&gt; &lt;div class="image"&gt; // image goes here &lt;/div&gt; &lt;div class="info"&gt; // data &lt;/div&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; </code></pre>
php
[2]
4,419,078
4,419,079
Compile time error on addition of two short variable [C#]
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/4343624/integer-summing-blues-short-short-problem">Integer summing blues, short += short problem</a> </p> </blockquote> <p>I have summarized my problem into following code snippet.I have two short vaiable and I am adding these two variable into another short variable,but I am getting compile time error.Why is it so?</p> <pre><code> 1.short x = 1, y = 1; 2.short z = x + y; </code></pre> <p><strong>Compile time error at line 2</strong> *<em>EDIT:</em>*</p> <pre><code>If short+short=int then why int+int !=long </code></pre>
c#
[0]
1,530,252
1,530,253
C# windows service sometimes hangs on Executing sql update
<p>I am doing a simple update, of a bit in a table using the code below. However, sometimes the program hangs on myCommand.ExecuteNonQuery(); and I don't know why. If Sql server is down, it will drop into the catch statement as expected but sometimes, for seemingly no reason, it will just hang on the execution statement. Any Ideas.... Some of my code is below.</p> <p>Thanks</p> <p>SqlCommand myCommand = new SqlCommand(sqlCommand); connection = new SqlConnection(constr); myCommand.CommandType = CommandType.Text;</p> <pre><code> myCommand.Connection = connection; try { connection.Open(); myCommand.ExecuteNonQuery(); } catch (Exception ex) { throw new Exception("There was an inserting information from the Sql server&lt;br&gt;" + "The server error was: &lt;br&gt;" + ex.Message + "&lt;br&gt;"); } finally { this.CloseConnection(); } </code></pre>
c#
[0]
5,610,383
5,610,384
Why android:uiOptions="splitActionBarWhenNarrow" not working with device
<p>I am using <code>android:uiOptions="splitActionBarWhenNarrow"</code></p> <p>to split the <code>Menu's</code> .it is working fine with emulator <code>4.03</code></p> <p>but not with real device <code>4.03</code>.It is samsung tablet</p>
android
[4]
3,722,395
3,722,396
how to refactor the following codes
<p>I have a method want to refactor, and some dummy codes as below:</p> <pre><code>if(deletedInfo.isEmpty() &amp;&amp; addedInfo.isEmpty()) { // some logic codes } else if (!deletedInfo.isEmpty() &amp;&amp; addedInfo.isEmpty()) { // some logic codes } else if (deletedInfo.isEmpty() &amp;&amp; !addedInfo.isEmpty()) { // some logic codes } else if(!deletedInfo.isEmpty() &amp;&amp; !addedInfo.isEmpty()) { // some logic codes } </code></pre> <p>is there a appropriate pattern or some algorithm to refactor this codes?</p> <p>Thanks.</p>
java
[1]
2,899,318
2,899,319
How to detect whether a keyboard is present or not
<p>How does android detects whether a keyboard is present or not? Which file I should modify if I need to change the way android detects the keyboard.</p>
android
[4]
5,127,775
5,127,776
What is difference between sys.exit(0) and os._exit(0)
<p>please help me in clarifying the concept of these two python statements in terms of difference/functionality.</p> <pre><code> 1. sys.exit(0) 2. os._exit(0) </code></pre>
python
[7]
5,791,347
5,791,348
Javascript Popup Text Limit in IE8
<p>Is there any limit to the amount of text that can be called via a Popup in javascript/jquery?</p> <p>I have a popup that works fine in IE9, FF etc BUT does NOT work in IE8</p> <p>The word count is 2667, is there any limitations in IE8 and can it be fixed via code?</p> <p>Update: When I edit the text, the popup works. Still curios why IE8 would not load </p> <p>Thanks</p> <p>RG</p>
javascript
[3]
3,085,794
3,085,795
const in c++ and memory folding
<p>when we declare the const variable it is said in Bruce eckel book that memory folding happens that means memory is not allocated for the variable I wanted to know what happens when we declare the variable as const</p>
c++
[6]
592,508
592,509
how to scroll scrollview horizontally
<p>hi i am new to iphone.I need to scroll scrollview horizontally instead of vertical.Is it possible to scroll horizontally.If it possible pls post link consist sample example.Thank u in advance. </p>
iphone
[8]
174,501
174,502
How to read file(bigger) in php from bottom up
<p>How to read files from bottom up in php?Is there something like stream in java which will read file incrementally but just backwards. Because my files can get up to 650 mb.</p>
php
[2]
4,475,365
4,475,366
Android selector - Text color
<p>the background of a button is set based on selectors defined as:</p> <pre><code> &lt;selector xmlns:android="http://schemas.android.com/apk/res/android" android:dither="true"&gt; &lt;item android:state_checked="true" android:drawable="@drawable/checked" /&gt; &lt;item android:state_focused="true" android:drawable="@drawable/focused" /&gt; &lt;item android:drawable="@drawable/normal"/&gt; &lt;/selector&gt; </code></pre> <p>How do I define the button's text color based on its state (pressed / focused)? This doesn't work:</p> <pre><code> &lt;selector xmlns:android="http://schemas.android.com/apk/res/android" android:dither="true"&gt; &lt;item android:state_checked="true" android:drawable="@drawable/checked" android:textColor="#CCCCCCCC"/&gt; &lt;/selector&gt; </code></pre>
android
[4]
1,413,368
1,413,369
Run Javascript Code
<p>I need to run javascript in php or python or java. My problem is, when a dynamic page load in browser some javascript executes and add some content on html. But if i download the file using wget or any programming language then i can not find the dynamic portion. I am giving you an example:</p> <pre><code>&lt;html&gt; &lt;body&gt; &lt;script type="text/javascript" &gt; document.body.innerHTML= "hello world"; &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>In the above code when i run the code in browser it shows hello world. But if i download the file or open with text editor i will see nothing. So i need to get the output using any programming language. For that i need to execute the javascript. [python,c/c++,php,javascript,java] any language.</p>
javascript
[3]
1,631,716
1,631,717
How to "map" an image
<p>I would like to know if there is a good way to "map" an image in android, I mean I have an image, figure a photo, and if an user taps on a body launch an activity, if he taps on a phone start something else and so on. I'm sorry if the question is stupid but it's way complicated google something you dont fully understand xD</p> <p>EDIT: googling something seems an imageMap function does not exists, so how can I manage different taps on a single image ?</p> <p>thanks in advance</p>
android
[4]
4,990,722
4,990,723
converting uchar in c++
<p>How do I convert a uchar to an int?</p>
c++
[6]
4,605,085
4,605,086
failing to open alert box before redirection.ASP.NET
<p>I'm trying to show an alert box before redirecting,but it's not working.The alert box only works if the redirection is not done.</p> <p>i modified the popular Alert.Show("string") class from Mads Kristensen as below....</p> <pre><code>public static class Alert { /// &lt;summary&gt; /// Shows a client-side JavaScript alert in the browser. /// &lt;/summary&gt; /// &lt;param name="message"&gt;The message to appear in the alert.&lt;/param&gt; public static void Show(string message) { // Cleans the message to allow single quotation marks string cleanMessage = message.Replace("'", "\\'"); //replacing script string with strSCript //string script = "&lt;script type=\"text/javascript\"&gt;alert('" + cleanMessage + "');&lt;/script&gt;"; //added this below string strScript = "&lt;script type=\"text/javascript\" language=\"javascript\"&gt;"; strScript += "alert('" + cleanMessage + "');"; strScript += "window.location.href='http://localhost/Gadgeteer/IncToH/IncToH.zip';"; strScript += "&lt;/script&gt;"; // Gets the executing web page Page page = HttpContext.Current.CurrentHandler as Page; // Checks if the handler is a Page and that the script isn't allready on the Page if (page != null &amp;&amp; !page.ClientScript.IsClientScriptBlockRegistered("alert")) { page.ClientScript.RegisterClientScriptBlock(typeof(Alert), "alert", strScript); } } } //calling from code behind Alert.Show("message"); </code></pre>
asp.net
[9]
5,789,035
5,789,036
Ending an Event Driven Function in JavaScript
<p>I am using JavaScript with HTML5. When the user clicks on a button, an event-driven JavaScript function starts up. When the user clicks on the button again, another instance of this function starts up. So I have two instances of the same function handling a event. However I only want the new instance to be running. How do I end the first instance of the?</p> <p>An example is a function with the following code</p> <pre><code>Canvas.paper = Raphael(xOffset,yOffset,imageWidth,imageHeight); masterBackground = Canvas.paper.rect(0,0,imageWidth,imageHeight); window.onkeydown=function(e){ // Event handler code } document.addEventListener('keydown', function(event) { // Event handler code } masterBackground.mousemove(function(e){ // Event handler code } </code></pre>
javascript
[3]
1,119,980
1,119,981
Making a key-command for a python program with no GUI
<p>I want to make a key command so that the program will stop running when the Ctrl key then the 'e' key then the 'x' key then the 'i' and 't' keys are hit. So basically when the program is running if you type Ctrl + exit, the program will stop running. There is no GUI and I don't want to do this via a python interpreter. </p> <p>The end goal is a program that will close if the Ctrl + exit command is typed, regardless of what other programs are in focus. This program is going to be a light weight key-logger, so having a GUI would be pointless. </p>
python
[7]
167,685
167,686
How to manipulate width of multiple images in javascript
<p>I have multiple images and i wnat to place all of them in a single line.How should i manipulate the width of images such that the sum of width of al images does not exceed the browser's width.??</p>
javascript
[3]
3,614,499
3,614,500
jQuery preventDefault
<p>Hi I have the following code: </p> <pre><code>collapsed.on('click', 'a',function(c) { c.preventDefault(); }); </code></pre> <p>Collapsed is basically a div element, inside this div there is an anchor tag which as it stands it does not work because of the prevent function. The prevent function needs to be there. Is there a way of getting that anchor tag working inside that div even with the preventDefault function?</p> <p>Let me know if you need more info.</p>
jquery
[5]
4,606,771
4,606,772
Replace text in textarea using Javascript
<p>I need to replace all the matches of a regular expression till the caret position in a textarea using Javascript. For example, if the text in the textarea is: "6 students carry 2 books to 5 classes" and the cursor is placed on books and the regular expression is /\d/, the numbers 6 and 2 should be replaced by, say, 4. I know the replace function and I know how to get the caret position, but how do I solve this problem? Thanks for any help in advance! </p>
javascript
[3]
233,979
233,980
Stacks and queues are giving errors in Dev-C++
<p>I was given and assignment to develop a cellphone simulation, part of the requirements includes me using a queue to store the phone numbers that come from a txt file to simulate getting called. I have reviewed over and over again and including #include but the error message telling me "Queue" undeclared still shows up. I am using Bloodsehd Dev-C++, and I have included a sample I used to test the queue, if it is just the program not having the right information, any help would be appreciated. I have checked other sites most say add a #include or a #include neither seemed to solve the problem.</p> <pre><code>#include &lt;queue&gt; #include &lt;deque&gt; #include &lt;iostream&gt; #include &lt;fstream&gt; using namespace std; class cell { public: cell(); ~cell(); void upload( string item );//Insert in order void printnew();//Print call just recieved void printlater();//Print calls for later int Front(); //returns front element int Rear(); //returns rear element bool Empty(); private: }; int main() { Queue Q; Q.Enqueue(54); cout &lt;&lt; Q.front(); system("Pause"); return 0; } </code></pre>
c++
[6]
474,356
474,357
javascript onblur/onfocus function not working
<p>I have the following two html form inputs:</p> <pre><code>&lt;input type="text" class="faded" name="mobile" value="012-245-6789" onfocus="hideDefault(this)" onblur="showDefault(this)"/&gt; </code></pre> <p>and </p> <pre><code>&lt;input class="faded validation_required" type="text" name="dob" value="MM/DD/YYYY" onfocus="hideDefault(this)" onblur="showDefault(this)"/&gt; </code></pre> <p>and the following javascript:</p> <pre><code>function hideDefault(input) { if(input.name == "dob") { if (input.value == "MM/DD/YYYY") { input.value = ""; input.style.color = "black"; } } else if(input.name == "mobile") { if (input.value == "012-345-6789") { input.value = ""; input.style.color = "black"; } } else {input.value ="hello";} } function showDefault(input) { if(input.name = "dob") { if (input.value == "") { input.value = "MM/DD/YYYY"; input.style.color = "#A3A3CC"; } } else if(input.name == "mobile") { if (input.value == "") { input.value = "012-345-6789"; input.style.color = "#A3A3CC"; } } } </code></pre> <p>The "dob" input is working fine, when you click on it the default text disappers and when you move off it it comes back. But its not working for the first one, the "mobile" one. Why is this?</p>
javascript
[3]
3,209,105
3,209,106
what does 'and' N 'or' exactly mean in python?
<p>im really confusing now, in my program thought model if you met an expression like these</p> <p>expr = expr1 and expr2</p> <p>which mean the expr's type must be Boolean,same thing to 'or' operations</p> <p>see the codes below, suppose the three lines will print booleans</p> <pre><code>print(1==1 and 3) print(1==2 and 3) print(1==2 and 3 or 4) </code></pre> <p>but the result is</p> <pre><code>3 False 4 </code></pre> <p>i have to restudy the basic programming :</p> <p>the true meaning of and and or 'e1 and e2' means evaluate e1 if the result is False return False else return e2 'e1 or e2' means evaluate e1 if the result is True return True else return e2</p> <p>do i get it right?</p>
python
[7]
1,208,000
1,208,001
MKMapView GPS location question
<p>I am a newbie.. I have a doubt in MapView and CoreLocation. How to make the mapview to display "blue dot and circle animation" as in Locate Me action of Maps app? The solution may be very simple, but I don't have much idea about map in iPhone. Help me, pls.</p>
iphone
[8]
2,668,777
2,668,778
$_GET in ASP and choose file
<p>I'm trying to write ASP for the first time, I've only been using PHP for some years and never really got in to ASP. What I want to do is to get a value from the URLs get. For instance the url is like: page.asp?id=1</p> <p>Then I want this value to be in an include like:</p> <pre><code>&lt;!--#include file="somepage_$_GET[id].html"--&gt; </code></pre> <p>How can this be achieved through ASP?</p> <p>Peace</p>
asp.net
[9]
1,006,318
1,006,319
what is the difference between "Basic Java" and " Core Java"?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/2000349/what-is-the-difference-between-java-and-core-java">What is the difference between java and core java?</a> </p> </blockquote> <p>please somebody help me with this question. thanks.</p>
java
[1]
3,134,833
3,134,834
how to access other file type through php
<p>im considering to create a resource file in php to read other file type??</p> <p>for instance, instead of calling the image / javascript directly, i shall pass a query string to this resource.php indicating the type of file, and it would perform the same function as it is originally.</p> <p>for instance: using <code>resource.php?type=js&amp;file=alertme.js</code> which would read alertme.js that alert("hello world");</p>
php
[2]
1,795,274
1,795,275
How do I check if a string is NOT a floating number?
<pre><code>var num = "10.00"; if(!parseFloat(num)&gt;=0) { alert("NaN"); } else { alert("Number"); } </code></pre> <p>I want to check if a value is not a float number, but the above code always returns <code>NaN</code>, any ideas what I am doing wrong?</p>
javascript
[3]
2,210,026
2,210,027
Java library to split text into smaller files
<p>I am looking for a java library that allows me to specify max size or max number of lines in output files, and then splits a large xml/text file into smaller files.</p> <p>I saw that there is a 2 year old question on SO for the same, however the answers there were for specific cloud platforms....I just want a library for use in java desktop apps.</p>
java
[1]
6,011,938
6,011,939
How to pass a value in jQuery
<p>I want to pass an error message. How do I do it and what do I need to change?</p> <pre><code> success: function(data) { var div = $('&lt;div&gt;').attr('id', 'message').html(data.message); if (data.success == 0) { $.modaldialog.error('The operation failed.'); ... </code></pre> <p>I want to replace the <code>div</code> with the error message that comes into this success function. I still need the id though I think because it is what toggles between the success and error block.</p> <hr> <p>'The operation failed.' should be replaced with the error message that is contained in 'data.message'.</p>
jquery
[5]
5,384,337
5,384,338
What advantages are gained by using namespaces in javascript?
<p>Apart from not cluttering the global namespace and gaining the ability to encapsulate code in private members, is there any benefit?</p>
javascript
[3]
3,215,145
3,215,146
jquery loading image while elements loads
<p>hi im looking for any tutorials/articels about inserting a loading gif while elements load, ive seen it in a few sites. i can only seem to find articles on preloading images. </p>
jquery
[5]
1,165,221
1,165,222
How can I randomize an entire string of 62 characters?
<p>I have 62 base64 characters that I want to randomize. How can I do this using PHP? The string would be all letters, upper and lower case as well as numbers from 0-9.</p> <p>The thing that is most important to me is that the entire string be evaluated before a return value is given. In other words, if I request a string of 8 characters in length and my string starts out like:</p> <p>1234567890ABCDE..... I don't want to get the first 8 numbers randomized. It should randomize the entire string first, then return 8 characters from that.</p>
php
[2]
5,921,385
5,921,386
file name image upload
<p>When I upload image filename contain "two words.jpg" (there a white space in the middle). It will not echo an error message. Does anyone have the same issue?</p> <p>PHP:</p> <pre><code>$file = $_FILES['Filedata']; if ($file["size"] &gt; 20000) {echo "Excess limit size"; die('EXCESS');} </code></pre>
php
[2]
266,902
266,903
Undefined Variable Loop
<p>I am new to Python. I get an error that says "undefined Variable". I could not figure it out. The statement in the code is the following:</p> <pre><code>Classroom1 = Classroom(FirstCourseStartTime = 8, LastCourseEndTime = 7.75) m_count = 0 h_count = 0 t_count = 0 l_count = 0 loopsize = 10000 Loop(Classroom1, m_count, h_count, t_count, l_count, loopsize) def Loop(Classroom1, m_count, h_count, t_count, l_count, loopsize): for i in range(0, loopsize): Mutated = Classroom() Mutated = Classroom1.CopyOfClassroom(Mutated) Mutated.Mutate() HardConstraintClassroomMet = Classroom1.ComputeHardConstraint() HardConstraintMutatedMet = Mutated.ComputeHardConstraint() if HardConstraintClassroomMet == False and HardConstraintMutatedMet == False: h_count + 1 t_count + 1 Classroom1.Mutate() continue if Mutated.FitnessValue() &gt; Classroom1.FitnessValue(): m_count + 1 t_count + 1 Classroom1 = Mutated if Classroom1.ComputeHardConstraint() == False: l_count + 1 temp = l_count*loopsize print "Unable to meet hard consraints in %d" % temp Loop(Classroom1, m_count, h_count, t_count, l_count, loopsize) </code></pre>
python
[7]
1,259,020
1,259,021
How would I reduce nesting for form validation in PHP?
<p>This is function is taking up a lot of lines on my Functions page. </p> <p>I can't figure out on how to take it down unless putting them into an array, then using a <code>foreach</code> loop. But I want it to be specific on what is not allowed to be blank.</p> <pre><code>if ($EmployeeID === "") { echo "EmployeeID Is Blank."; } else { if ($Firstname === "") { echo "Firstname Is Blank."; } else { if ($Lastname === "") { echo "Last Name Is Blank"; } else { if ($PhoneNumber === "") { echo "Phone Number Is Blank"; } else { if ($Address === "") { echo "Address Is Blank"; } else { if ($City === "") { echo "City Is Blank"; } else { if ($State === "") { echo "Sate Is Blank"; } else { if ($Zip === "") { echo "Zip Is Blank"; } else { if ($Email === "") { echo "Email Is Blank"; } else { if ($Password === "") { echo "Password Is Blank"; } else { echo "All Success"; } } } } } } } } } } </code></pre> <p>The Solution I have Found which takes the lines down, but doesn't give me the exact on what field is left empty is:</p> <pre><code>$Array = array(); $Array[] = $EmpID; $Array[] = $FirstName; $Array[] = $Lastname; $Array[] = $PhoneNumber; $Array[] = $Address; $Array[] = $City; $Array[] = $State; $Array[] = $Zip; $Array[] = $Email; $Array[] = $Password; foreach ($Array AS $Checking) { if (empty($Checking)) { echo "One Or More Is Left Blank"; exit; } } </code></pre>
php
[2]
2,408,911
2,408,912
Update missed calls notification on android
<p>I need to cancel the missed calls notification for a certain number. I've seen the NotificationMgr class on com.android.phone but i'm unable to call it trough reflection. Is there any other way?</p>
android
[4]
1,301,576
1,301,577
A randomly generated 20 character's alpha-numeric key
<p>How can i create A randomly generated 20 character's alpha-numeric key in asp.net i need to save it i database on some link click.</p>
asp.net
[9]
4,995,669
4,995,670
Why is a duplicate random string generated by C# method
<p>The following method generates a random string with the given length.</p> <p>When executed twice in a row, the same string is given. Is anybody able to shed any light on why this might be?</p> <pre><code> public static string GenerateRandomString(int size, bool lowerCase) { StringBuilder builder = new StringBuilder(); Random random = new Random(); char ch; for (int i = 0; i &lt; size; i++) { ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65))); builder.Append(ch); } if (lowerCase) return builder.ToString().ToLower(); return builder.ToString(); } </code></pre>
c#
[0]
4,613,801
4,613,802
Replace Backslashes with Forward Slashes in Python
<p>I'm writing a cross platform file explorer in python. I am trying to convert any backslashes in a path into forward slashes in order to deal with all paths in one format.</p> <p>I've tried not only using string.replace(str, '\\', '/'), but also creating a method manually to search through the string and replace the instances, and both do not work properly, as a path name such as: </p> <pre><code>\dir\anotherdir\foodir\more </code></pre> <p>changes to:</p> <pre><code>/dir/anotherdir\x0oodir/more </code></pre> <p>I am assuming that this has something to do with how Python represents escape characters or something of the sort. How do I prevent this happening?</p>
python
[7]
4,318,473
4,318,474
how to update listview periodically in android
<p>my listview is not updated periodically in android it only updates when i scroll the listview then only its adapter changes</p> <pre><code>final Thread dataThread=new Thread(new Runnable() { public void run() { getFiveNearShops(); DataBaseHelper myDbHelper = new DataBaseHelper(mContext); myDbHelper = new DataBaseHelper(mContext); try { myDbHelper.createDataBase(); } catch (IOException ioe) { throw new Error("Unable to create database"); } try { myDbHelper.openDataBase(); mCountyAndShops = myDbHelper.getCountyList(); shopCountyData = myDbHelper.getShopCountyData(); } catch(SQLException sqle) { throw sqle; } finally { myDbHelper.close(); } } }); dataThread.start(); Thread displayThread = new Thread(new Runnable() { public void run() { try { dataThread.join(); } catch (InterruptedException e) { e.printStackTrace(); } mHandler.post(new Runnable() { public void run() { EfficientAdapter listPlacesAdapter = new EfficientAdapter(getApplicationContext()); list_places.setAdapter(listPlacesAdapter); list_places.setDivider(null); mapOverlays.add(itemizedoverlay); listPlacesAdapter.notifyDataSetChanged(); list_county.setAdapter(new CountyListEfficientAdapter(getApplicationContext(),mCountyAndShops)); list_county.setDivider(null); } }); } }); displayThread.start(); </code></pre>
android
[4]
1,660,833
1,660,834
Preventing any Activity from vanish while intent from activty to activity
<p>in my project i have a several activities.. but i have a one (parent) activity... from that activity i intend to other activities for getting data from other activities.. my problem is while indent back to my parent activity all details entered before were gone...can any one assist me how preserve those data's... thanks in advance..</p>
android
[4]
4,996,665
4,996,666
running clock and triggering
<p>constantly running a clock and trigger an other function for every 5 seconds.</p> <p>Please give me idea how to do this.</p> <p>Thanks a bunch </p>
python
[7]
4,072,188
4,072,189
Query about arrayadapter
<pre><code>ArrayAdapter&lt;String&gt; arrayadapter=new ArrayAdapter&lt;string&gt;(Sipnner_apActivity.this,android.R.layout.simple_spinner_item,arrarylist); </code></pre> <p>Here what is the meaning of <code>android.R.layout.simple_spinner_item</code> and why does the <code>Arrayadapter</code> class belong to <code>widget</code> class &amp; why not belong to "util" class.</p> <p>thank you.</p>
android
[4]
3,628,114
3,628,115
java static variables
<p>i have two java files file1 and file2 as follows in package pak </p> <p>file1:</p> <pre><code>package pak; public class file1 { public static int x=432; public static void main(String[] args){ System.out.println("y is "+file2.y); while(x==432) { System.out.println("x is "+file1.x); } } } </code></pre> <p>file 2:</p> <pre><code>package pak; public class file2 { public static int y=46; public static void main(String[] args){ System.out.println("x is "+file1.x); ++file1.x; System.out.println("x is "+file1.x); } } </code></pre> <p>i will run first file1 and it will be running and when i run file 2 from another shell it should increment x value and it should come out of loop in file 1 can some one pls help me ??????</p>
java
[1]
254,928
254,929
php while loop output producing select for each item
<p>I know I have coded this incorrectly, but cannot seem to find a way to correct it. The aim, is to have a dropdown displayed populated with results from mysql database. It is currently displaying a dropdown for every address. I know why this is happening but cannot seem to correct it. Should the echo be out of the while loop? or is the placement correct but it is wrong somewhere else? would be gratful if someone could check it and inform me where i AM GOING WRONG WITH IT. Many thanks.</p> <pre><code>&lt;?php $customer = mysql_real_escape_string( $_GET["customer"] ); $con = mysql_connect("localhost","root",""); $db = "sample"; if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db($db, $con); $query_rs_select_address2 = sprintf("SELECT * FROM company_com where idcode_com = '$customer'"); $rs_select_address2 = mysql_query($query_rs_select_address2, $con) or die(mysql_error()); $row_rs_select_address2 = mysql_fetch_assoc($rs_select_address2); $totalRows_rs_select_address2 = mysql_num_rows($rs_select_address2); while ($row_rs_select_address2 = mysql_fetch_assoc($rs_select_address2)) { $address=$row_rs_select_address2['address1_com']. " ". $row_rs_select_address2['address2_com']. " ". $row_rs_select_address2['address3_com']. " ". $row_rs_select_address2['town_com']. " ". $row_rs_select_address2['postcode_com']; echo '&lt;select name="customer"&gt;'.'&lt;option value=""&gt;Select delivery address&lt;/option&gt;'.'&lt;option value="address"&gt;'.$address.'&lt;/option&gt;'.'&lt;/select&gt;'; } ?&gt; </code></pre>
php
[2]
2,863,373
2,863,374
is there any limit for using window.open() in javascript
<p>Is there any limit of using <code>window.open("URL");</code> in JavaScript? <br> when I tried to open three windows using <code>window.open("URL")</code> after opening the second window the third window didn't open separately but it just refreshed the contents of first window and showed the contents of the third window in there.</p>
javascript
[3]