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,514,982 | 3,514,983 |
Python beginner, strange output problem
|
<p>I'm having a weird problem with the following piece of code.</p>
<pre><code>from math import sqrt
def Permute(array):
result1 = []
result2 = []
if len(array) <= 1:
return array
for subarray in Permute(array[1:]):
for i in range(len(array)):
temp1 = subarray[:i]+array[0]+subarray[i:]
temp2 = [0]
for num in range(len(array)-1):
temp2[0] += (sqrt(pow((temp1[num+1][1][0]-temp1[num][1][0]),2) + pow((temp1[num+1][1][1]-temp1[num][1][1]),2)))
result1.append(temp1+temp2)
return result1
a = [['A',[50,1]]]
b = [['B',[1,1]]]
c = [['C',[100,1]]]
array = [a,b,c]
result1 = Permute(array)
for i in range(len(result1)):
print (result1[i])
print (len(result1))
</code></pre>
<p>What it does is find all the permutations of the points abc and then returns them along with the sum of the distances between each ordered point. It does this; however, it also seems to report a strange additional value, 99. I figure that the 99 is coming from the computation of the distance between point a and c but I don't understand why it is appearing in the final output as it does.</p>
|
python
|
[7]
|
3,056,581 | 3,056,582 |
loading nav controller from tabbarview controller on iphone
|
<p>my app is based on tabbar controller
now in my default view i am showing a viewController and lets say it has <strong>Button A</strong>, when user press A it should <strong>load a my tableviewController but nothing is happening?</strong>?</p>
<pre><code>-(IBAction)promo:(id)sender
{
aRoot= [[tableViewController alloc] initWithNibName:@"tableViewController" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:aRoot animated:YES];
}
</code></pre>
<p>but its not loading anything no error even???</p>
<p>/////////// UPDATE</p>
<p>i did this </p>
<pre><code>- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
Promo *aPromo = [[Promo alloc] initWithNibName:nil bundle:nil];//button A is deifned on this VC
// then...
aNav = [[UINavigationController alloc] initWithRootViewController:aPromo];
// [pageOne release];
</code></pre>
<p>and in promoviewController</p>
<pre><code>-(IBAction)promo:(id)sender
{atab= [[TableViewController alloc] initWithNibName:@"TableViewController" bundle:nil];
//TableViewController *atab1 = [[TableViewController alloc]initWithNibName:@"TableViewController" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:atab animated:YES];
}
</code></pre>
|
iphone
|
[8]
|
2,942,849 | 2,942,850 |
Developing high load sites with java
|
<p>Is there any web sites written with java that serve millions of users?</p>
<p>From what I've seen, popular web sites generally using php, asp.net. Is this because of servlet technology or development costs?</p>
<p>===============After close===========</p>
<p>I am currently developing web applications using JSF ,Spring MVC +JQUERY . In the past ,I had developed web applications using asp.net . Applications we developed are seems to me and Workmates(they have mostly php experince) slow .So we want to know ,</p>
<p>Are we missing something or Servlet technology come with cons.</p>
<p>For this, I ask the question and its a reasonable question.</p>
|
java
|
[1]
|
1,585,297 | 1,585,298 |
Draw Path jquery with the following coords
|
<p>i have to draw a path, i get the following coordinats!</p>
<p><a href="http://i.stack.imgur.com/h1Sw3.gif" rel="nofollow">http://i.stack.imgur.com/h1Sw3.gif</a></p>
<p>i think s = startpoint, f = finishpoint.
my problem are the attributes (ax, ay, bx and by)</p>
<p>may someone could show me an example (with jquery svg or raphael?)</p>
<p>Thanks</p>
|
jquery
|
[5]
|
304,786 | 304,787 |
How can I filter some touch events and let them pass from one view to another in Android?
|
<p>I want to do either of the following. </p>
<p>1) Only allow swipe/fling on my view and disable single taps, long press and other events.</p>
<p>or</p>
<p>2) Overlay another view on top of my view and only allow swipe/fling/scroll events to pass through to the view below it.</p>
<p>Is it possible to do it in Android?</p>
|
android
|
[4]
|
5,726,871 | 5,726,872 |
Question on Event name of javascript
|
<p>I want to ask a question about the javascript event. I have a <code><input type="text"></code> box and I have applied the autocomplete function on that box.</p>
<p>I know that when the user types the char like "sta" in the box and the javascript will call the <code>keypress</code> event, which also calls the autocomplete function. </p>
<p>However, I want to know what event of the javascript will be called what I use the mouse to click/click the keybroad "enter" to the wanted item from the autocomplete list. Thank you.</p>
|
javascript
|
[3]
|
5,283,831 | 5,283,832 |
Use drawable with ShaderFactory in LayerDrawable
|
<p>I am having trouble using a Drawable with ShaderFactory in a LayerDrawable. It is showing all black instead of to the two layers (none of which should be all black). It worked when I used a static Shader using drawable.getPaint().setShader(), but not now with ShaderFactory. </p>
<pre><code>ShapeDrawable.ShaderFactory sf = new ShapeDrawable.ShaderFactory() {
@Override
public Shader resize(int width, int height) {
Log.d("shader", width+"x"+height);
LinearGradient gradient = new LinearGradient(0, 0, width, height,
new int[] { 0x33FF0000, 0x00000000, 0x00000000, 0x11000000 },
new float[] { 0.0f, 0.04f, 0.97f, 1.0f }, Shader.TileMode.CLAMP);
return gradient;
}
};
ShapeDrawable grad = new ShapeDrawable();
grad.setShaderFactory(sf);
Drawable[] layers = new Drawable[] { anotherDrawable, grad };
Drawable d = new LayerDrawable(layers);
someImageView.setImageDrawable(d);
</code></pre>
|
android
|
[4]
|
1,850,782 | 1,850,783 |
Recommended books to learn Java / web applets
|
<p>I come from a few years experience in .NET, and played a bit with
Java during my uni studies.</p>
<p>Could you recommend any good books to learn the best ways to
develop a Java web applet?</p>
|
java
|
[1]
|
4,402,956 | 4,402,957 |
Creating an empty list in Python
|
<p>What is the best way to create a new empty list in Python?</p>
<pre><code>l = []
</code></pre>
<p>or</p>
<pre><code>l = list()
</code></pre>
<p>I am asking this because of two reasons:</p>
<ol>
<li>Technical reasons, as to which is faster. (creating a class causes overhead?)<br/></li>
<li>Code readability - which one is the standard convention.</li>
</ol>
|
python
|
[7]
|
1,445,076 | 1,445,077 |
Threading not possible suggest any other way to do parallel processing
|
<p>My code in C# which i put in threading is not thread safe as it involves lots of database connections, stored procedure executions. but still i want to minimize the time required for the execution, can anyone suggest me something for parallel or asynchronous processing.. anything from database side or .net side...</p>
<p>I am stuck with threading.. not able to apply... </p>
<p>Thanks</p>
|
c#
|
[0]
|
4,301,847 | 4,301,848 |
Exception in thread "main" Java.lang.NoSuchMethodError: main?
|
<pre><code>import java.io.*;
import java.lang.Math;
class Squr
{
public static void main ()
{
int m =10,n;
double z = 10.4,p;
Squr square = new Squr();
p = (double)square.mysqrt(z);
n = (int)square.mysqrt(m);
System.out.println ("square root of 10 : " + n );
System.out.println ("square root of 10.4 : "+ p );
}
double mysqrt (double y)
{
return Math.sqrt(y);
}
int mysqrt (int x)
{
return (int)Math.sqrt(x);
}
}
</code></pre>
<p>This code is compiling but when we try to execute it it giving " Exception in thread "main" Java.lang.NoSuchMethodError: main "</p>
|
java
|
[1]
|
3,669,983 | 3,669,984 |
JavaScript variables scope and underscore.js
|
<p>I have a function, with this inside it:</p>
<pre><code>var fobj = function(){};
var my_obj = fobj.extend({
test: function(){
this.year = 1999;
my_fmagic.doMagic([
{
field: 'year',
type: 'function',
value: function(data_from_doMagic){
console.log(data_from_doMagic, this.year);
return data_from_doMagic == this.year;
}
}
]);
}
});
</code></pre>
<p>Then, the <code>doMagic</code> function:</p>
<pre><code>var fmagic = function(){};
var my_fmagic = fmagic.extend({
doMagic: function( rules ) {
var data_from_doMagic = 1999;
_.each(rules, function(rule) {
switch(rule.type) {
case "function":
var f = _.wrap(rule.value, function(func){
return func( data_from_doMagic );
});
f();
break;
}
});
}
});
</code></pre>
<p>The idea is: pass an array of "rules" to <code>doMagic</code> and let it do the rest.</p>
<p>Expected result: <code>test()</code> should return <code>true</code> (well, in this example it won't return anything, obviously, because there's no return, but the <code>value</code> field of the rule should be <code>true</code>.) </p>
<p>Problem: Instead the result being <code>true</code> it's <code>false</code>, because the function <code>f()</code> in <code>doMagic</code> doesn't know what the variable <code>year</code> is, and so it compares "1999" with "undefined".</p>
<p>As you can see I know where the problem is, but I can't think about any solution.</p>
<p>Ideas?</p>
<p>Regards</p>
|
javascript
|
[3]
|
1,927,964 | 1,927,965 |
Lowering script memory usage in a "big" file creation
|
<p>it looks like I'm facing a typical memory outage problem when using a PHP script.</p>
<p>The script, originally developed by another person, serves as an XML sitemap creator, and on large websites uses quite a lot of memory.</p>
<p>I thought that the problem was related due to an algorithm holding data in memory until the job was done, but digging into the code I have discovered that the script works in this way:</p>
<ul>
<li>open file in output (will contain XML sitemap entries)</li>
<li>in the loop:
---- for each entry to be added in sitemap, do fwrite</li>
<li>close file</li>
<li>end</li>
</ul>
<p>Although there are no huge arrays or variables being kept in memory, this technique uses a lot of memory.</p>
<p>I thought that maybe PHP was buffering under the hood the fwrites and "flushing" data at the end of the script, so I have modified the code to close and open the file every Nth record, but the memory usage is still the same.... I'm debugging the script on my computer and watching memory usage: while script execution runs, memory allocation grows.</p>
<p>Is there a particular technique to instruct PHP to free unsed memory, to force flushing buffers if any?</p>
<p>Thanks</p>
|
php
|
[2]
|
5,433,579 | 5,433,580 |
Changing class of a div using parent's id - jquery
|
<p>In my page there is an <code><a></code> tag and inside that there is a <code><div></code>. that is shown below: </p>
<pre><code> <a id="test" title="Change Color Code" href="#" class="modalDlg">
<div class="<%:(colorCode) %>">
</div>
</a>
</code></pre>
<p>How can i change the class of <code><div></code> when i click on another button in that page ( i only have the id of the hyperlink (ie , test ) ).</p>
<p>Can i change the class of that <code><div></code> using the hyperlink id (which contains that div) using jquery ?</p>
|
jquery
|
[5]
|
4,037,617 | 4,037,618 |
How to use EmbossMaskFilter?
|
<p>I want to add Emboss effect in my Custom design.I will really appreciate if someone can help me using EmbossMaskFilter in program.</p>
<pre><code> public void onDraw(Canvas canvas){
Paint mPaint=new Paint();
mPaint.setStyle(Paint.Style.FILL);
mPaint.setColor(Color.WHITE);
canvas.drawPaint(mPaint);
mPaint.setAntiAlias(true);
mPaint.setMaskFilter(new EmbossMaskFilter(new float[] { 1, 1, 1 },
0.4f, 10, 8.2f));
mPaint.setColor(Color.GREEN);
canvas.drawRect(60, 350, 200, 400, mPaint);
</code></pre>
|
android
|
[4]
|
3,507,390 | 3,507,391 |
Removing newlines in php
|
<p>Following is the syntax for <code>preg_replace()</code> function in php:</p>
<pre><code>$new_string = preg_replace($pattern_to_match, $replacement_string, $original_string);
</code></pre>
<p>if a text file has both Windows (rn) and Linux(n) End of line (EOL) characters i.e line feeds.</p>
<p>then which of the following is the correct order of applying <code>preg_replace()</code> to get rid of all end of line characters?</p>
<ol>
<li><p>remove cr first</p>
<pre><code>$string = preg_replace('|rn|','',$string);
$string = preg_replace('|n|','',$string);
</code></pre></li>
<li><p>remove plain nl first</p>
<pre><code>$string = preg_replace('|n|','',$string);
$string = preg_replace('|rn|','',$string);
</code></pre></li>
</ol>
|
php
|
[2]
|
3,906,086 | 3,906,087 |
how to play audio using audiotrack in android
|
<p>I'm developing an android app that will play mp3 files. However the mp3 files are encrypted on the sd card . Either ways, after decryption, i'll have a stream of bytes. I hav used audio track class but unable to play the audio.plz help me.
thank you in advance.</p>
|
android
|
[4]
|
4,335,854 | 4,335,855 |
What does the MediaPlayer message "internal/external state mismatch corrected" mean?
|
<p>I've been doing some pretty complex things with the MediaPlayer. Unlike <a href="http://stackoverflow.com/questions/7399286/android-media-player-internal-external-state-mismatch">Android Media Player internal external state mismatch</a>, I'm only working with audio, not video. The MediaPlayer class is notoriously fragile and unintuitive, so it's difficult to work around its quirks. I've been doing the best I can, but still run into difficult-to-diagnose bugs.</p>
<p>In this case, I occasionally see the error message "internal/external state mismatch corrected". I have no idea why. I'm running multiple MediaPlayers simultaneously, using MediaRecorder and then playing it in a MediaPlayer, stopping and starting and resetting and seeking... at least some of the time it seems to occur after start().</p>
<p>Is this a bug in Android, or am I doing something wrong? Can anyone tell me what this error message represents, and if there's something I should be doing differently or if I can safely ignore it?</p>
|
android
|
[4]
|
1,109,747 | 1,109,748 |
Cant Get a result form random.shuffle in python
|
<p>I have never had this problem before but when i try and shuffle a list i get a return of 'None' </p>
<pre><code>import random
c=[1,4,67,3]
c=random.shuffle(c)
print c
</code></pre>
<p>The print statement returns 'None' and i dont know why, I have looked around for an answer to this problem but there doesent seem to be anything. I hope i am not making an obvious mistake.</p>
|
python
|
[7]
|
3,282,255 | 3,282,256 |
Rounding a double
|
<p>Hey guys, I am trying to round to 3 decimal places.</p>
<p>I used the following code.</p>
<pre><code>this.hours = Round(hours + (mins / 60), 3);
</code></pre>
<p>But it's not working.
Where have I gone wrong?
Thanks</p>
|
java
|
[1]
|
2,426,507 | 2,426,508 |
How to let java to substitute chars in string and make it executable
|
<p>I haven't found any information if it's even possible. I want to use method or some other way to return string and put it into for loop so that when loop executes it can put loop parameters into returned string and compose new string. As you probably guess I want to insert keyStr into hashmap but with substitutions as is done in dynamicKeyStr. dynamicKeyStr solution is great but it's structure may change over time that's why I cannot write it statically.</p>
<p>Sometimes it's:</p>
<pre><code>dynamicKeyStr = array[i][1]+"-"+array[i][3]+"-"+array[i][8];
</code></pre>
<p>Another time it's:</p>
<pre><code>dynamicKeyStr = array[i][13]+"-"+array[i][5];
</code></pre>
<p>and so on.</p>
<pre><code>public void dynamicForLoop() {
for (int i = 0; i < array.length; i++) {
String dynamicKeyStr = array[i][1]+"-"+array[i][3]+"-"+array[i][8];
//String KeyStr = "array[i][1]+\"-\"+array[i][3]+\"-\"+array[i][8]";
hashSet.add(dynamicKeyStr);
}
}
</code></pre>
|
java
|
[1]
|
497,954 | 497,955 |
How to start and monitor an external command line process with java under windows XP
|
<p>I have a java question about launching and monitoring external processes under Windows XP.</p>
<p>I have written a coommand-line simulation program with C++ and mingw which takes an XML file as input file. I am now writing a pre-processor for that program (I call it "Launcher"). </p>
<p>Launcher allows user to edit parameters and save to an XML file, it also provides ability to start simulation process with an input file and kill the simulation process when it's still running. In order to do this, it must be able to monitor the launched command-line simulation process.</p>
<p>In Launcher, I created a new thread and I used <code>ProcessBuilder</code> or <code>Runtim.getRuntime()</code> method in its <code>run()</code> function to start simulation process. The command used to construct ProcessBuilder to start external simulation program was as follows:</p>
<pre><code>cmd.exe /c start <simulation program> -i <input file>
</code></pre>
<p>The simulation process did start as I expected with above command and a command window appears.However, the thread which contains this Process object ends immediately. Therefore, I couldn't track the process and terminate it from Launcher program.</p>
<p>I modified the command to following:</p>
<pre><code>cmd.exe /c start /wait <simulation program> -i <input file>
</code></pre>
<p>The thread used to start this process didn't end until the command-line window running the simulation process ended.
However, when I tried to interrupt this thread, the thread did end but the external simulation process didn't. Therefore, I still can't kill that process from my java program.</p>
<p>I have studied this problem for two days, most materials I found are focusing on how to start an external process but not focusing on monitoring it after it started. I hope I can find a simple and elegant way to start an external command-line process with Java under XP while I still can monitor and terminate that command-line process through the Java program which starts it.</p>
|
java
|
[1]
|
3,838,757 | 3,838,758 |
How can i get the buttons to launch a intent
|
<p>How can I get the buttons to link to a intent so when user clicks on one of these arrays it would load up a new java file?</p>
<pre><code>final CharSequence[] items = {"Red", "Green", "Blue"};
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Pick a color");
builder.setItems(items, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
Toast.makeText(getApplicationContext(), items[item], Toast.LENGTH_SHORT).show();
}
});
AlertDialog alert = builder.create();
</code></pre>
|
android
|
[4]
|
3,278,346 | 3,278,347 |
Does the API provide scroll buttons for ListView
|
<p>I have a client who wants a conventional scrollbar for ListViews in their application. The reason why is because this application will be used exclusively with their devices which happen to feature resistive screens. The screens don't track gestures very well without a stylus and a stylus will not always be available to the user. Hence the conventional scrollbar as a fallback UI control. A fast scroll thumb will not be a useful solution to this problem.</p>
<p>What I have found in the API that is of some use are xml attributes which allow me to approximate the behaviour of the track and thumb such as:</p>
<pre><code>android:scrollbarAlwaysDrawVerticalTrack="true"
android:scrollbarStyle="insideInset"
android:fadeScrollbars="false"
</code></pre>
<p>But I haven't found anything in the API that would take care of including scroll buttons at the top and bottom of the track. </p>
<p>Am I correct in concluding that the API does not provide this functionality?
If so, my only option would be to use a couple of buttons that change the list position. This is a doable solution of course but I wanted to make sure that I wasn't reinventing yet another wheel.</p>
<p>I have to support as far back as 2.2.</p>
<p>Scrollbar Example:</p>
<p><img src="http://i.stack.imgur.com/Ahs57.gif" alt="Scrollbar example"></p>
|
android
|
[4]
|
1,848,178 | 1,848,179 |
jquery Multiselect
|
<p>how to sort jquery multiselect based on selected values??? I would like to show selected option first in jquery multiselect, followed by all unselected vales.</p>
<pre><code> like below multiselect having two values selected
<select id="the-select">
<option value="1">First option</option> \\selected
<option value="2">Second option</option>
<option value="3">Third option</option>\\selected
</select>
but i need to show the multiselect as its showing below
<select id="the-select">
<option value="1">First option</option> \\selected
<option value="3">Third option</option>\\selected
<option value="2">Second option</option>
</select>
Thanks
</code></pre>
|
jquery
|
[5]
|
3,796,783 | 3,796,784 |
error in xml file
|
<p>i am preparing my android apps in which i want to create two row .it showing this error on the second tableRow.but i couldn't understand,how to resolve that error.
the error is "The markup in the document following the root element must be well-formed."it is coming on the second table row</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<TableRow
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/tableRow1">
<!-- Screen Design for the SONGS -->
<ViewFlipper android:id="@+id/viewFlipper1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ViewFlipper>
</TableRow>
<TableRow
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:id="@+id/tableRow2"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</TableRow>
</code></pre>
|
android
|
[4]
|
2,644,692 | 2,644,693 |
Simultaneous code in javascript?
|
<p>How do I have two separate functions run simultaneously? If I wanted two clocks, one to count up and the other to count down, and I wanted them to run at the same time, how would I do it?</p>
<p>If I just did:</p>
<pre><code>var up = 1;
while(true){
document.write(up);
up++;
if(up==11)
up=1;
}
var down = 10;
while(true){
document.write(down);
down--;
if(down==0)
down=10;
}
</code></pre>
<p>...it would just keep counting up...</p>
|
javascript
|
[3]
|
235,210 | 235,211 |
Logical OR operator in string comparison?
|
<p>Why does this comparison fails? How do I compare for alternating strings in csharp ?</p>
<pre><code>Static void Main(string[] args)
{
string varFoo = "cat";
if (varFoo != "cat" || varFoo!="duck")
Console.WriteLine("You can enter.");
else
Console.WriteLine("Not allowed.");
Console.ReadLine();
}
</code></pre>
<p>Just wanted something as</p>
<pre><code>If(Either cat or a Duck)
// You're not allowed
else
// you are welcomed.
</code></pre>
|
c#
|
[0]
|
5,401,093 | 5,401,094 |
How to Create personal online radio station?
|
<p>I want to create my own radio station, that is I will host my application , e-g: <a href="http://myradiostation.com" rel="nofollow">http://myradiostation.com</a> on a server from godaddy or any other hosting company. that application will have a music player , user can come to that website and listen to music and they can also talk with the RJ. </p>
<p>Now, how to input above website with music and talk streams? </p>
<p>I want to do it in Asp.NET . I do not want to use any third party because I do not have money to buy these.</p>
|
asp.net
|
[9]
|
3,001,031 | 3,001,032 |
java Calendar get(calendar.MONTH) returns 0
|
<p>Why does calendar.get(calendar.MONTH) return 0(zero) here: ?</p>
<pre><code>Date date = new SimpleDateFormat("yyyy-mm-dd").parse("2013-02-12");
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
System.out.println( calendar.get(calendar.MONTH) ); // 0 ??
</code></pre>
|
java
|
[1]
|
1,610,499 | 1,610,500 |
Determine if empty $_POST submitted
|
<p>I have a form containing tabular data, with each row having a checkbox with the same name so that it gets passed via POST as an array to a PHP page. Everything work fine, but I have an issue relating to when none of the items on the page are selected - this is a special case that I need to handle in a specific way, but I am trying to figure out how to determine the best way to tell when this condition occurs, as when it does the <code>$_POST</code> array is completely empty.</p>
<p>Any strategies to help in determining when an empty set of data has been POSTed to a page in PHP?</p>
|
php
|
[2]
|
3,289,389 | 3,289,390 |
how can i pass anonymoustype to asp.net mvc 2 view?
|
<p>i am learning asp.net mvc 2 but i have a problem that i can pass the anonymous type to the view.
Here is the code :</p>
<pre><code>DBDataContext db = new DBDataContext();
var gca = from x in db.tbl_controllers
select new
{
x,
tblAction = (from y in db.tbl_actions
select new
{
y,
visible = (from z in db.tbl_controller_actions
where z.actionId == x.id && z.controllerId == y.id
select z).Single<tbl_controller_action>() == null ? false : true,
isExisted = (from t in db.tbl_group_controller_actions
where t.groupId == id && t.controllerId == x.id && t.actionId == y.id
select t).Single<tbl_group_controller_action>() == null ? false : true
}),
};
</code></pre>
<p>How can I pass the gca to the view ?
Thank you very much.</p>
|
asp.net
|
[9]
|
3,238,917 | 3,238,918 |
Does each of java API function map to java native method?
|
<p>Does each of java API function map to java native method?</p>
<p>If not then how those functions get the functions of operating system? </p>
|
java
|
[1]
|
4,494,616 | 4,494,617 |
Solving engine for TicTacToe
|
<p>I'm a junior programmer and I know the basics of pascal and c++. I made a Tic Tac Toe game with Player-Computer and the game is all finished.</p>
<p>The computer generates a random place where the Os go on the table and that's not good.</p>
<p>I thought that i should multiple procedures that check every winning position and the computer should else try to block the player's Xs or to make a winning position, BUT this would have been lots of time lost cause all of the if's.</p>
<p>Then I thought of a simpler version with some kind of ifs but it would still have been taking lots of time to do.</p>
<p>Then i thought deeper: What about a find-four game? How in the earth someone would manage to check every space available and how it would've been possible that someone could make a function that checks absolutely any winning or progress of player/computer position, Oh and wait, that's not ALL, what if the player is doing some tricks so he blocks the computer? How would the computer know that?!? For sure, that would take ages to program. And I am not talking about something that seems more impossible: Chess.</p>
<p>So here I am, asking myself that there SHOULD be a way more simpler way the computer should search and solve some problems than tons of ifs. </p>
<p>In this case, if any of you know any way of solving this, how can i manage to make the simplest procedure to block and beat the player in a TicTacToe game?</p>
<p>If someone wants to check my code or use it: <a href="http://pastebin.com/jhyUn7d1" rel="nofollow">http://pastebin.com/jhyUn7d1</a></p>
|
c++
|
[6]
|
487,996 | 487,997 |
PHP if() evaluation problem needs a rewrite
|
<p>I noticed this weird evaluation yesterday after searching for a few hours in my code for an error. i am passing scores into php, sometimes the score=0 which causes an issue.</p>
<p>send php ?blah=blah&score=0</p>
<pre><code>if(!empty($_REQUEST['score']){
//do database update stuff
}else{
// show entire webpage
}
</code></pre>
<p>It works great unless the score=0 the if() will evaluate to false and return the entire webpage to my ajax handler and error. I have temporarily changed !empty to isset but this will cause problems in the future because isset evaluates to true even if the score key is in the url string without a value.<br>
ex: (?blah=blah&score=&something=else)</p>
<p>my question is: what is the best way to recode this to work correctly now and in the future?</p>
<p>edit: there are a few working answers here, i appreciate everyones time. it was difficult to choose an answer</p>
|
php
|
[2]
|
3,206,885 | 3,206,886 |
Why do we need `class` in C++?
|
<p>Using <code>struct</code> we can achieve all the functionalities of a <code>class</code>:</p>
<ul>
<li>constructors, destructors </li>
<li>member functions, static functions.</li>
<li>overloaded functions, virtual functions </li>
<li>public / private / protected access specifiers.</li>
<li>operators</li>
</ul>
<p>The only difference are the default access rights: private for class, public for struct.<br>
Why do we need a Class then ?</p>
|
c++
|
[6]
|
1,512,889 | 1,512,890 |
Or and not equal
|
<p>Why does this work?</p>
<pre><code>#include <iostream>
#include <string>
using namespace std;
int main(){
string s="a";
if((s=="cm")||(s=="in")||(s=="ft")||(s=="m"))
cout<<s+" Is an illegal value";
else
cout<<"I like "+s;
return 0;
}
</code></pre>
<p><a href="http://ideone.com/7pnYh" rel="nofollow">http://ideone.com/7pnYh</a></p>
<p>but then this doesnt</p>
<pre><code>#include <iostream>
#include <string>
using namespace std;
int main(){
string s="a";
if((s!="cm")||(s!="in")||(s!="ft")||(s!="m"))
cout<<s+" Is an illegal value";
else
cout<<"I like "+s;
return 0;
}
</code></pre>
<p><a href="http://ideone.com/TXUXA" rel="nofollow">http://ideone.com/TXUXA</a>
The answer i want for both is "I like a" .</p>
|
c++
|
[6]
|
3,736,966 | 3,736,967 |
Android Record Audio
|
<p>i found that code to record, but I always get:</p>
<p>The method setOutputFile(FileDescriptor) in the type MediaRecorder is not applicable for the arguments (Uri)</p>
<p>So how would I need to describe the filepath that it works?
thx</p>
<pre><code>// Prepare recorder source and type
MediaRecorder recorder = new MediaRecorder();
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
// File to which audio should be recorded
File outputFile = getFileStreamPath("output.amr");
Uri target = Uri.parse(outputFile.getAbsolutePath());
recorder.setOutputFile(target);
// Get ready!
recorder.prepare();
// Start recording
recorder.start();
// Stop and tidy up
recorder.stop();
recorder.release();
</code></pre>
|
android
|
[4]
|
3,557,122 | 3,557,123 |
How can I "remove" the disabled attribute on click?
|
<p>I couldn't quite get it to work properly. I'm trying to remove the disabled attribute on click so that I can edit it.</p>
<p>My jQuery:</p>
<pre><code>$('#edit-credentials').click(function() {
$('#credentials :input').prop("disabled", !$('#credentials:input').prop("disabled"))
});
</code></pre>
<p>HTML: </p>
<pre><code><a id="edit-credentials" onclick="return false;" href="#">edit</a>
<div id="credentials">
<input disabled="disabled">
<input disabled="disabled">
</div>
</code></pre>
|
jquery
|
[5]
|
3,920,526 | 3,920,527 |
Xml error in Android
|
<pre><code><?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout
android:id="@+id/widget41"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
>
<TextView
android:id="@+id/widget62"
android:layout_width="300px"
android:layout_height="292px"
android:text="Patient education is an integral part of health care delivery across medical centers in developed countries thus encouraging active patient participation and ensuring far better compliance and patient satisfaction. It was this very dream that inspired Dr. Aniruddha and Dr. Anjali Malpani, who founded HELP in 1997, with a dream to make each and every individual in this country aware of his rights and responsibilities as a patient, of ways people could reduce the burden of health care expenses by planning and educating themselves "before" a serious medical problem could strike their family, and how doctors and patients could join hands to achieve health for all. What started as a resource center eleven years back, with a modest collection of material on patient education, in their day care center at Om Chambers, has grown into India's only largest patient education center housing more than 11,000 authentic books on possibly every aspect of health and diseases, along with pamphlets, health care magazines, and an exhaustive audiovisual section too"
android:layout_x="10px"
android:layout_y="32px"
>
</TextView>
<Button
android:id="@+id/widget63"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Next"
android:layout_x="130px"
android:layout_y="352px"
/>
</AbsoluteLayout>
</code></pre>
<p>I am getting this error and what's wrong in this?</p>
<blockquote>
<p>Multiple annotations found at this
line:
- No grammar constraints (DTD or XML schema) detected for the document.
- Element type "TextView" must be followed by either attribute
specifications, ">" or "/>".
- error: Error parsing XML: not well-formed (invalid token)</p>
</blockquote>
|
android
|
[4]
|
2,175,465 | 2,175,466 |
how to save file with illegal name
|
<p>Here is how I'm creating a file:</p>
<pre><code>System.IO.File.Create(Server.MapPath("..") + name + ".html");
</code></pre>
<p>But sometimes name has illegal characters, like å, from the swedish alphabet. How to save them? It is possible directly, but I get error when I do it with code.</p>
|
c#
|
[0]
|
1,897,503 | 1,897,504 |
Facebook: Get user's Facebook UID with Javascript
|
<p>How do I get facebook username, uid, photo and other info with Javascript.</p>
<p>I remember that you had to write something like: .id or .gender for each thing you wanted to get but I don't remember the code at all and can't find the documentation.</p>
<p>How do I get the user UID and Gender with Javascript ?</p>
<p>Thanks</p>
|
javascript
|
[3]
|
1,683,222 | 1,683,223 |
Javascript - why this loop ? instance->(prototype property->constructor property->function object->constructor property)
|
<p>I am unable to understand this loop behavior of the javascript.</p>
<p>Can someone tell me why was it designed in this way?
Is there any real use case of this behavior?</p>
<p>why this loop? {
Newly created instance inherits properties from the prototype property of the constructor function object.
prototype property of the constructor function is an object that keeps constructor property.
constructor property is equal to the constructor function object.
Again constructor function object keeps prototype property.
}</p>
<p>instance1---inhertis(keeps)-->Prototype property of func()-->keep constructor property-->function object func-->keep prototype property.</p>
<pre><code>var func = function(){};
var construct = func.prototype.constructor;
console.log(construct === func); //true
var instance1 = new func();
</code></pre>
<p>Updated: Even if in between i assigned something else, instanceof always returns true.</p>
<pre><code>var func1 = function(){};
func1.prototype.constructor = 1;
var instance1 = new func1();
console.log(instance1 instanceof func1); //true
var func2 = function(){};
func2.prototype.constructor = 0;
var instance2 = new func2();
console.log(instance2 instanceof func2); //true
</code></pre>
<p>Sorry to ask 2 question in 1 but both may be related.</p>
|
javascript
|
[3]
|
4,903,126 | 4,903,127 |
Give a hint to user at the time of installation time only
|
<p>I am doing a project in which,i have to give the user a message at the time of installation only.After that the message should be hidden.Now whenever i run the program the message will be displayed.I want to avoid it. I want to do it programatically in android.Can anyone help to resolve this issue?</p>
<p>Thanks in Advance</p>
|
android
|
[4]
|
3,883,037 | 3,883,038 |
Need help executing a .bat file using PHP
|
<p>I am trying to execute a .bat file (m.bat) using a simple php script: </p>
<pre><code><?php
if(isset($_POST['submit']))
{
echo exec('m.bat');
echo "Done!";
} else {
?>
<form action="" method="post">
<input type="submit" name="submit" value="Run">
</form>
<?php
}
?>
</code></pre>
<p>this just displays the content of the .bat file in the browser, and if I drop the 'echo' before 'exec' it does nothing at all. :( </p>
|
php
|
[2]
|
4,280,601 | 4,280,602 |
extract last two fields from split
|
<p>I want to extract last two field values from a variable of varying length. For example, consider the three values below:</p>
<pre><code>fe80::e590:1001:7d11:1c7e
ff02::1:ff1f:fb6
fe80::7cbe:e61:f5ab:e62 ff02::1:ff1f:fb6
</code></pre>
<p>These three lines are of variable lengths. I want to extract only the last two field values if i split each line by delimiter :</p>
<p>That is, from the three lines, i want:</p>
<pre><code>7d11, 1c7e
ff1f, fb6
ff1f, fb6
</code></pre>
<p>Can this be done using <code>split()</code>? I am not getting any ideas.</p>
|
python
|
[7]
|
37,938 | 37,939 |
Detailed error on fopen
|
<p>I'm using fopen to read from a file</p>
<pre><code>$fh = fopen($path, 'r') or die('Could not open file');
</code></pre>
<p>Now I contantly get error Could not open file. I checked the file path and even changed the permissions of the file to 777. Is there a way I can get a detailed error report as why the file can't be opened similar to mysql_error()?</p>
|
php
|
[2]
|
1,711,532 | 1,711,533 |
Setting a boolean attribute with jquery
|
<p>I understand that jquery will allow you to modify attributes with the .attr() method. There are basically two methods:</p>
<pre><code>$('#element').attr('attribute', 'value') // sets the attribute
var attribute = $('#element').attr('attribute') // gets the attribute
</code></pre>
<p>My question is, how do you set a boolean attribute such as 'checked' on a checkbox or 'multiple' on a select tag?</p>
<p>I've tried doing the following without success:</p>
<pre><code>$('#element').attr('attribute', true)
$('#element').attr('attribute', '')
</code></pre>
<p>All of these add the attribute but usually like this </p>
|
jquery
|
[5]
|
2,057,768 | 2,057,769 |
var DB*; in C++
|
<p>My professor sent back a short email:</p>
<pre><code>int x = 100;
var HT*;
HT = new int[x];
</code></pre>
<p>Firstly:
Compiling the code (with other stuff around it to make it "work"):
error: 'var' does not name a type.</p>
<p>Second:
This is for hash tables. Apparently this is the way to create an array of variable size according to the ANSI standard (G++ has extensions that we can't use or he'll shoot us).</p>
<p>Any ideas?</p>
|
c++
|
[6]
|
3,430,332 | 3,430,333 |
comma syntax javascript
|
<p>Can someone help me understand what the next line means? What is - </p>
<pre><code>elem,.style.height = ( pos /100) * h + "px";
</code></pre>
<p>There's a comma right after elem.</p>
<pre><code>function slideDown( elem ){
//
elem.style.height = '0px';
show(elem);
var h = fullHeight(elem);
for (var i = 0 ; i <= 100; i+= 5){
(function(){
var pos = i;
setTimeout(function(){
elem,.style.height = ( pos /100) * h + "px";
}, (pos + 1) * 10 );
})();
}
}
</code></pre>
|
javascript
|
[3]
|
2,566,293 | 2,566,294 |
How to import static functions with deploy variable class name?
|
<p>I'm developing cross-platform OpenGL game for computer and Android. </p>
<p>For computer platform i use LWJGL:</p>
<pre><code>import static org.lwjgl.opengl.GL20.*;
</code></pre>
<p>For Android platform i use:</p>
<pre><code>import static android.opengl.GLES20.*;
</code></pre>
<p>I don't want create interface GL and wrap these functions and i don't want write same classes twice with different imports. I know it's possible, because Java is compiled into native when it's launched. </p>
|
java
|
[1]
|
5,287,602 | 5,287,603 |
What is a reasonable size of JavaScript?
|
<p>What is the maximum size of JavaScript that would be reasonable for a web page? I have a JavaScript program with a data segment of size about 130,000 bytes. There is virtually no whitespace, comments, or variables in this file which could be minified. The file looks something like this:</p>
<pre><code>"a":[0],
"b":[0,5],
"c":[3,4,24],
"d":[0,1,3],
</code></pre>
<p>going on for several thousand lines.</p>
<p>Google Analytics gives the following info on the connection speed of the current users:</p>
<pre>
Rank Type Visitors
1. DSL 428
2. Unknown 398
3. Cable 374
4. T1 225
5. Dialup 29
6. ISDN 1
</pre>
<p>Is the file size too much?</p>
<p>The alternative is using a server-side program with Ajax.</p>
|
javascript
|
[3]
|
4,618,150 | 4,618,151 |
How to debug VS-2008 application which is hosted in IIS ver 5.1
|
<p>I have written some JavaScript to do client-side validation. If I press F5 to execute the application, everything is working fine. But, if I host the application in IIS and if I run from IIS, JavaScript validation is not working at-all.</p>
<p>Can anybody tell what could be the reason?</p>
<p>Hence, I want to debug the application which is hosted in IIS. I am using IIS ver 5.1. How can I debug? means, what processes to attach?</p>
<p>Thanks in advance</p>
|
asp.net
|
[9]
|
4,062,310 | 4,062,311 |
onListItemClick() show diffrent-2 activities
|
<p>i have responceid (String responceid = Activity2.getData()) for every row ...i want when i click on any position of list item it show its corresponding responceid ...so how to bind responseid for every row ....<strong>responceid takes from database</strong></p>
<pre><code>@Override
protected void onListItemClick(ListView l, View v, int position, long id)
{
super.onListItemClick(l, v, position, id);
String responceid = Activity2.getData();
Object o = (String) (Notepadv3.this).getListAdapter().getItem(position);
Toast.makeText(this, "this row responce id is= " + " " + , Toast.LENGTH_LONG).show();
}
</code></pre>
|
android
|
[4]
|
332,435 | 332,436 |
android: checksum for string
|
<p>Does anyone know an easy way to generate a checksum for a String on an Android? I have a NMEA sentence I have generated in a String class and it is ready to be sent, but it needs a checksum to be appended. </p>
|
android
|
[4]
|
5,039,303 | 5,039,304 |
how can I upload my application to android market
|
<p>I have an .apk file.I want to upload my application to android market,without using eclipse.
I have already signin.but I am getting an error.that is..**</p>
<p><strong>M*arket does not accept apks signed with the debug certificate. Create a new certificate that is valid for at least 50 years.<em>*</em></strong></p>
<p>thank you</p>
|
android
|
[4]
|
2,173,884 | 2,173,885 |
How can I use open hardware monitor source code in c# ? I tried anything doesn't work
|
<p>I have this code in Form1:</p>
<pre><code>using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using OpenHardwareMonitor.Hardware.HDD;
using OpenHardwareMonitor;
namespace OpenHardwareMonitor
{
public partial class Form1 : Form
{
OpenHardwareMonitor.Hardware.SensorValue sv;
OpenHardwareMonitor.Hardware.ISensor ii;
public Form1()
{
InitializeComponent();
string y = ii.Name;
sv = new Hardware.SensorValue();
DateTime dt = sv.Time;
float t = sv.Value;
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
}
</code></pre>
<p><code>ii</code> variable is null I don't know how to make an instance for it.</p>
<p>The other two variables in the constructor return 0 nothing. If I'm not using the <code>ii</code> variable the other two don't throw an error but don't return any values.</p>
<p>I'm using the openhardwaremonitor dll from <a href="http://code.google.com/p/open-hardware-monitor/downloads/detail?name=openhardwaremonitor-v0.4.0-beta.zip&can=2&q=" rel="nofollow">http://code.google.com/p/open-hardware-monitor/downloads/detail?name=openhardwaremonitor-v0.4.0-beta.zip&can=2&q=</a></p>
<p>The c# dll is coming with the program it self.</p>
<p>So I added as reference the dll but I don't know how to make the code.</p>
<p>Could someone build for me just an example of the code according to my code here ?
I tried to look in the openhwardwaremonitor site and source code there and didn't understand how to use it.</p>
<p>What else can I do ?</p>
<p>Thanks.</p>
|
c#
|
[0]
|
988,780 | 988,781 |
Javascript Prototyping Question
|
<p>I'm just reading about Prototypes in JavaScript and Douglas Crockford offers and excellent way to select a new objects prototype but can anyone explain (below) why obj01's type equals 'object' when I pass it in function as it's prototype?</p>
<pre><code>if (typeof Object.beget !== 'function') {
Object.beget = function (o) {
console.log(typeof o);//function
var F = function () {};
F.prototype = o;
console.log(typeof F);//function
return new F();
};
}
var func01 = function(){};
var obj01 = Object.beget(func01);
console.log(typeof obj01);//object
console.log(typeof obj01.prototype);//object
</code></pre>
<p>I thought it would be </p>
<pre><code>console.log(typeof obj01);//function
console.log(typeof obj01.prototype);//function
</code></pre>
|
javascript
|
[3]
|
4,480,699 | 4,480,700 |
asp.net Domain / Subdomain Authentication not working correctly
|
<p>I have a w2k3 server which hosts 2 sites under iis, such that I have Mysite.com and foo.mysite.com</p>
<p>I am trying to use forms authentication and single sign on.</p>
<p>Both sites have the same machine key, and the same domain prefixed with a . in the web.configs.</p>
<p>The 2 issues I have are;</p>
<p>1) If I go to <a href="http://www.mysite.com/login.aspx" rel="nofollow">http://www.mysite.com/login.aspx</a>, and login, then navigate to the subdomain it redirects me back to the login page. </p>
<p>But if I go to <a href="http://mysite.com/login.aspx" rel="nofollow">http://mysite.com/login.aspx</a> and login, then navigate to the subdomain it works. so why is it seeing www.mysite.com and mysite.com as seperate domains and thus invalidating my authentication?</p>
<p>It is my understanding that adding domain=".mysite.com" would work for all sub sites under the domain.</p>
<p>2) If I change the subdomain login url to be mysite.com not www.mysite.com and hit the subdomain first, it redirects to the login form fine, but when I log in it does not redirect to the subdomain, rather it looks for the subdomain page on the main site. i.e. Browse to foo.mysite.com/bar.aspx, it redirects to the login page, and when logged in it now tries to show mysite.com/bar.aspx not the page I first requested.</p>
<p>Any help explaining and resolving these issues is most welcome!</p>
<p>Thanks</p>
<p>As an update to this. I found a workround to the redirect issue elsewhere on this site. Dont know why it doesnt work as I'd expect, but I can now cross that one off.</p>
<p>Secondly (on my test system anyway) programatically specifying the domain works with www. whereas using domain="" in teh config file does not.</p>
|
c#
|
[0]
|
2,696,514 | 2,696,515 |
JQuery fadeOut then load
|
<p>I'm fairly new to JQuery and I am having a problem with fading out and then loading afterwards.</p>
<p>My code is:</p>
<pre><code>$("#refresh").live("click", function() {
$("#postbit").fadeOut("slow");
$("#postbit").load('load.php').fadeIn("slow");
return false;
});
</code></pre>
<p>But it doesn't seem to work. It works fine if I don't have the fadeOut before and just have it load. But is there a way to make it first fadeOut and then having it fadeIn slowly :)</p>
<p>Thanks</p>
|
jquery
|
[5]
|
3,393,895 | 3,393,896 |
Including If In Arrays Formed Using For
|
<p>In Python I have this statement:</p>
<pre><code>blog_ids = [c.blog_id for c in connections]
</code></pre>
<p>Which basically tells Python to create an array of all the blog IDs in the connections. Unfortunately, if the <code>connections</code> object has some <code>None</code> types, <code>c.blog_id</code> would cause an exception. Is there any syntax to solve this problem? I tried this but it doesn't work:</p>
<pre><code>blog_ids = [c.blog_id for c not None in connections]
</code></pre>
|
python
|
[7]
|
1,533,922 | 1,533,923 |
What is the best way to do 'Reset Password' functionality in php?
|
<p>What is the best way to do 'Reset Password' functionality in php ?</p>
<p>Two step process. </p>
<ul>
<li><p>User will enter the email Id, mail will send him to user with the link.</p></li>
<li><p>When user click the link, he can see tow fields to reset his password.</p></li>
</ul>
<p>Can anybody right the script flow for this ?</p>
|
php
|
[2]
|
2,439,338 | 2,439,339 |
How to show/hide DOM element with jQuery?
|
<p>There are button (id= "hide_message_button") and message(id="message"). The click on the button should hide/show the message. The source code:</p>
<pre><code>$('#hide_message_button').click(function(){
var bool = $('#message').css('visibility','hidden').is(':hidden');
if(bool){
$('#message').show();
$(this).val('Hide');
}
else {
$('#message').hide();
$(this).val('Show');
}
});
</code></pre>
<p>I have a bug: the message is hidden with first click on the button and didn't shown again (but button's value is changed to 'Show'). What's wrong? Thanks.</p>
|
jquery
|
[5]
|
2,525,447 | 2,525,448 |
Multiple Sessions or Multidimensional array?
|
<p>I haven't got any data to benchmark this, so beforehand i'd like to know. What would you say would perform better with PHP with multiple users loading the same page? </p>
<p>1.100 sessions on a page each containing an array which each are unset at the end of the code 2.Multidimensional array: an array with 100 keys each containing an array. </p>
|
php
|
[2]
|
3,762,217 | 3,762,218 |
Creation of linkedList in java directly if we know the elements
|
<pre><code> List<String> ll = new LinkedList<String>("String1","String2",...);
</code></pre>
<p>I want something like above.
Is the above line possible in java...?</p>
|
java
|
[1]
|
5,918,900 | 5,918,901 |
ExpandoObject (dynamics) my greatest friend or my new greatest foe?
|
<p>Yes I know that it shouldn't be abused and that C# is primariy used as a static language. But seriously folks if you could just dirty up some code, in the python style, or create some dynamic do hicky, would you?</p>
<p>My mind is working overtime on this having spent a while loving the dynamics of python, is c# going over to the dark side through the back door?</p>
<p>Is the argument for static typing a dead one with this obvious addition?</p>
<p>Is the argument for less Unit testing a bit silly when we are all grown ups?</p>
<p>Or has the addition of dynamics ruined a strongly static typed and well designed language?</p>
|
c#
|
[0]
|
4,745,017 | 4,745,018 |
Load Users into jQuery during onLoad of a page for a Live Search
|
<p>All,
I've got the following code to which is basically a function that loads some search terms in it when the DOM is loading:</p>
<pre><code>window.myAutocompleteFunction = function(){
return ['Test Saying','sit amet consectetur adipiscing','elit Nulla et justo'];
};
</code></pre>
<p>This works fine for my live search and updates correctly. I'm trying to populate these values based on some information from my database though. I tried to update my code to use a .get function to populate my return values and I tried to make it look like this:</p>
<pre><code>window.myAutocompleteFunction = function(){
$.get('http://localhost/website/load_users.php', function(data) {
alert(data);
return [data];
});
};
</code></pre>
<p>It tries to load the users and in my alert it is the same as when it's manually typed in but for some reason when I do the search it doesn't work. Any idea how to get the same results from my file and have the search work the same?</p>
<p><strong>EDIT:</strong> The only thing in my load_users.php file right now is the following:</p>
<pre>
'Test Saying','sit amet consectetur adipiscing','elit Nulla et justo'
</pre>
<p>I'm going to try and populate that with database values but just trying to get this to work for now.</p>
<p><strong>Another Edit:</strong> I also tried to make my code like the following just to see if it work work:</p>
<pre><code>window.myAutocompleteFunction = function(){
jQuery.get('http://localhost/okyne/load_users.php', function(data) {
alert(data);
return ['Test Saying','sit amet consectetur adipiscing','elit Nulla et justo'];
});
};
</code></pre>
<p>This doesn't work either so I'm not sure why it wouldn't work and the only thing that works for me so far is the first code snippet that I provided.</p>
<p>Any help you can provide is greatly appreciated!</p>
|
jquery
|
[5]
|
4,377,090 | 4,377,091 |
Insert an Image into a video file in IOS
|
<p>I want to dynamically insert a picture into a video file for an iPhone app. What I was trying to do was a chromakey and replace a color in the video with the image I wanted. Does anyone knows a tutorial or framework for IOS that i can use? Or how could I proceed?</p>
<p>Thx</p>
|
iphone
|
[8]
|
2,471,835 | 2,471,836 |
upload files to the server in .net
|
<p>I am writing an application in .NET Winform. The data files produced are required to upload to our server. </p>
<p>I dont know what are the approaches supporting for this? The one came to my mind immediately is FTP. Is there any other way in .NET Winform?</p>
<p>Thanks in advance. </p>
|
c#
|
[0]
|
5,856,411 | 5,856,412 |
PHP Concatenation using {}
|
<blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/2596837/curly-braces-in-string">curly braces in string</a> </p>
</blockquote>
<p>I still don't know what it's called. Like:</p>
<pre><code>$name = 'xxx';
echo "This is a string {$name}";
</code></pre>
<p>What do you call that operation? Concatenating a variable using {} in to a string.</p>
<p>Thanks!</p>
|
php
|
[2]
|
769,528 | 769,529 |
NSArray adding elements
|
<p>I have to create a dynamic NSArray. That is I dont know the size of the array or what are all the elements the array is going to have. the elements need to be added to the array dynamically. I looked at the NSArray class reference. there is a method called arrayWithObejcts, which should be used at the time of initializing the array itself. But i dont know how to achieve what I need to do. please help me.</p>
<p>I need to do some thing like the following:</p>
<pre><code>NSArray *stringArray = [[NSArray init] alloc] ;
for (int i = 0; i < data.size; i++){
stringArray.at(i) = getData(i);
}
</code></pre>
|
iphone
|
[8]
|
5,575,162 | 5,575,163 |
jquery ui sortable table columns with fixed rows issues
|
<p>There is a jquery ui sortable widget <a href="http://dbrink.github.com/sorttable/examples.html" rel="nofollow">extension</a> which makes table columns sortable.
According to examples page it is possible to specify row as undruggable. </p>
<pre><code> $(function () {
$('#ex7').sorttable({
placeholder: 'placeholder',
helperCells: ':not(.footerrow td)'
}).disableSelection();
});
</code></pre>
<p>I want to set several colspanned rows such way.
But there are several issues occur when i set fixed rows in the middle of the table.
First - fixed rows is not showed as dragged during drag&drop, second - after several movements table becomes broken.</p>
<p><a href="http://jsfiddle.net/NyQPD/6/" rel="nofollow">jsfiddle example</a></p>
<p>Is there any way to correct it?</p>
<p><strong>UPDATE:</strong></p>
<p>found workaround using absolute positioned div with width=table width, but actually i don't like it</p>
<p><a href="http://jsfiddle.net/NyQPD/10/" rel="nofollow">jsfiddle example</a></p>
|
jquery
|
[5]
|
5,476,048 | 5,476,049 |
c# autoupdate for share path
|
<p>I want to deploy my project with "Click Once" deployment. But when i did it like that, it is asking for "A new version is available, do you want to update ?" dialog box at end user machine. But my end users are NOT having mouse or keyboard. So my intention is: It must take the updates automatically but it must NOT ask that dialog box at client side. Can you please let me know how to achieve this by using "Click Once" deployment ?</p>
|
c#
|
[0]
|
2,598,226 | 2,598,227 |
play selected songs
|
<p>I have a reqiurement, I need to play multiple audio songson ASP.Net page.Can anyone suggest the best way to implement this.</p>
<p>I have page. There I will display the list of the songs in grid view. The gridview contains checkboxes and songs name. User should able to select the multiple check boxes and click play.</p>
<p>When ever user click play button on new popup window I have to play the all audio songs selected by user one by one.</p>
<p>I will appreciate your help.</p>
|
asp.net
|
[9]
|
971,905 | 971,906 |
jQuery loading a url when a thumb loads
|
<p>Let's say I have a mini app that consists of title, thumb, lg_image, url fields. I am loading in these thumbs dynamically by looping over the queryset. Each record has a url in the url field, how would I go about making the lg_image clickable to go to that url field? if it's any help I am using <a href="http://coffeescripter.com/code/ad-gallery/" rel="nofollow">http://coffeescripter.com/code/ad-gallery/</a> and basically I need the larger image to navigate to a url provided. I hope this is clear, it was a tad tough to explain. Please advise if not.</p>
<p>Thanks</p>
<ul>
<li>JeffC</li>
</ul>
|
jquery
|
[5]
|
3,511,867 | 3,511,868 |
C# - Truncating after a position
|
<p>I have a double typed variable. This variable stores information that is part of a more complex formula. Importantly, this variable can only include information up to the tenths location, or one decimal position (i.e. 10.1, 100.2, etc). However, when determining this value, it must be calculated such that anything past the tenths location is truncated, not rounded. For instance:</p>
<p>if the value equals 10.44, The variable value should be 10.4.
if the value equals 10.45, The variable value should also be set to 10.4</p>
<p>How do I truncate values in C# with respect to a decimal place?</p>
|
c#
|
[0]
|
3,781,844 | 3,781,845 |
Using instance variables as named format substitutions
|
<p>I am writing a Python program that generates a C++ program. There are a whole bunch of instances of code like this:</p>
<pre><code>class TestBlock(object):
def __init__(self, mod, name, casetype, generator):
self.mod = mod
self.name = name
self.casetype = casetype
self.generator = generator
def fullname(self):
return "{mod}.{name}".format(**self.__dict__)
def write_cases(self, outf):
outf.write("const {casetype} {mod}_{name}[] = {{\n"
.format(**self.__dict__))
for case in self.generator():
outf.write(" { " + case + " },\n")
outf.write("};\n\n")
</code></pre>
<p>The <code>"text {subst}".format(**self.__dict__)</code> construction is the only way I have found to make the instance variables of <code>self</code> available as named substitutions, and it's ugly and I do not like it. I would like to be able to write <code>"text {subst}".format(self)</code>; is this possible, and if so, how? I'm aware that <code>"text {0.subst}".format(self)</code> will work out of the box and <code>"text {subst}".format(**self)</code> can be made to work with a few special methods, but both of those still have extra gunk.</p>
|
python
|
[7]
|
3,592,584 | 3,592,585 |
Mapping on a image programatically
|
<p>HI all,</p>
<p>Client given me a particular area map image. Here i need to get the longitude and latitude of the location at the Touch point on the image.</p>
<p>Is there any way i can work on this issue. To get the location of touch point on the image programatically.</p>
<p>Thank you In advance</p>
|
android
|
[4]
|
3,333,336 | 3,333,337 |
How do I use a default setting from Root.plist?
|
<p>I have set up a default setting for my app using Root.plist, giving this a Boolean DefaultValue of YES (ticked checkbox).You can see a screengrab at <a href="http://www.infin8design.com/clients/stack/plist.png" rel="nofollow">http://www.infin8design.com/clients/stack/plist.png</a></p>
<p>However, when my app is first launched, the YES value is not picked up, and the setting is read as a NO (or 0). The user has to manually go into the settings app, turn the toggleswitch off, then turn it back on again for this setting to hold a YES(1) value.</p>
<p>I'm logging the value with appDidFinishLaunching like this.</p>
<pre><code>- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSLog(@"%d",[defaults boolForKey:@"include_phrases"]);
</code></pre>
<p>SO... my question is... How do I pick up this initial default setting without the user having to set it manually?</p>
<p>Thanks in advance for any suggestions you can offer.</p>
<p>Mark</p>
|
iphone
|
[8]
|
1,997,490 | 1,997,491 |
Form buttons over-writing timeout events in javascript
|
<p>I'm developing a javascript based application and have continued to run into an issue that seems like a producer/consumer problem (it happens in both IE and firefox).</p>
<p>:Program Description:</p>
<p>There are two divs (A and B) in the page. A function is scheduled with timeouts to flip between the two divs every N seconds.</p>
<p>divs B has a form in it with buttons. the buttons have an on click call back set to them - the call back resets (refreshes) the form.</p>
<p>:Implementation Bug/Problem:</p>
<p>When div B displays and a user clicks on the buttons multiple times, the function (scheduled by a timeout) to flip the two divs never seems to execute. If it does execute, the display content is shown so quickly, it's as if the timeout was never called.</p>
<p>I've tried using a globally scoped state variable to control when button presses should be shut off, but that does not seem to work. Any advice or recommendations is welcome! Thanks!</p>
<p>Example</p>
<p>Imagine a 2 second window between each, the following diagram explains how it works with no onclick mouse events:</p>
<pre><code>seconds 0 2 4 6
+----+----+----+
divs A B A B
</code></pre>
<p>NOTE: the top row are the 2 second intervals, the bottom row are the div flip events</p>
<p>with mouse on click events it should do something like this (A is scheduled to happen exactly at 4 seconds):</p>
<pre><code>seconds 0 2 4 6
+----+----+----+
divs A BBBBBA B
</code></pre>
<p>what it currently does:</p>
<pre><code> seconds 0 2 4 6....
+----+----+----+....
divs A BBBBBBBBBBB....
</code></pre>
<p>the scheduled A event never happens.</p>
|
javascript
|
[3]
|
1,129,911 | 1,129,912 |
What is the Control Name
|
<p><img src="http://i.stack.imgur.com/lZLd4.jpg" alt="enter image description here"></p>
<p>Hi all I want to make a control like in image.Is there any control in Framework?</p>
|
c#
|
[0]
|
149,482 | 149,483 |
Is there a simple command to hide or display an imageview?
|
<p>I have a series of imageviews that I want to display, but on a button press there needs to be less or more. These imageviews are stored in a list. Is there a simple way to hide or display them?</p>
|
android
|
[4]
|
1,062,264 | 1,062,265 |
Python strip() multiple characters?
|
<p>I want to remove any brackets from a string. Why doesn't this work properly?</p>
<pre><code>>>> name = "Barack (of Washington)"
>>> name = name.strip("(){}<>")
>>> print name
Barck (of Washington
</code></pre>
|
python
|
[7]
|
3,146,796 | 3,146,797 |
Android Network Provider sometimes stop using WiFi and start using Cell Tower even then person is still on same place. How to avoid that?
|
<p>Android Network Provider sometimes stop using WiFi and start using Cell Tower even then person is still on same place. How to avoid that?</p>
<p>I have tested several apps. Google maps, mapquest, glympse. Only google maps works correct. My own app, mapquest and glympse show wrong location based on cell towers instead of using wifi. Im 100% sure that wifi location is available, because after about 20 minutes it starts using wifi.</p>
|
android
|
[4]
|
358,543 | 358,544 |
config.inc directly opening in a browse window . How to avoid that
|
<p>we have a config.inc file in our website, that directly opening in the browser window. It has some credentials written in that config.inc file. how to avoid that opening from the browser. </p>
<pre><code>eg. www.example.com/config/config.inc
output
<?php
some credentials
?>
</code></pre>
<p>any sugesstions</p>
|
php
|
[2]
|
2,874,483 | 2,874,484 |
Tuple to string with a function to each element
|
<p>There is a tuple <code>(a, b, c)</code>. </p>
<p>I need to get <code>foo(a) + "\n" + foo(b) + "\n" + foo(c)</code></p>
<p>How it can be done in a smart way, not manually? </p>
|
python
|
[7]
|
2,873,138 | 2,873,139 |
PHP code polisher - exists anywhere?
|
<p>Could you please recommend some software that will do PHP code polishing according to pre-defined formatting rules?</p>
<p>Thanks!</p>
|
php
|
[2]
|
530,021 | 530,022 |
How to get UIView's Position in DrawRect method
|
<p>I have 4 views and i am drawing circles inside these views.The user is able to move these views.How can i get the position of each view?</p>
|
iphone
|
[8]
|
4,486,592 | 4,486,593 |
Reading in 4 bytes at a time
|
<p>I have a big file full of integers that I'm loading in. I've just started using C++, and I'm trying out the filestream stuff. From everything I've read, it appears I can only read in bytes, So I've had to set up a char array, and then cast it as a int pointer.</p>
<p>Is there a way I can read in 4 bytes at a time, and eliminate the need for the char array?</p>
<pre><code>const int HRSIZE = 129951336; //The size of the table
char bhr[HRSIZE]; //The table
int *dwhr;
int main()
{
ifstream fstr;
/* load the handranks.dat file */
std::cout << "Loading table.dat...\n";
fstr.open("table.dat");
fstr.read(bhr, HRSIZE);
fstr.close();
dwhr = (int *) bhr;
}
</code></pre>
|
c++
|
[6]
|
5,583,767 | 5,583,768 |
what's the size of hex value of some memory address converted to int or other type?
|
<p>For example:</p>
<pre><code>int* x = new int;
int y = reinterpret_cast<int>(x);
</code></pre>
<p><code>y</code> now holds the integer value of the memory address of variable <code>x</code>.
Variable <code>y</code> is of size <code>int</code>. Will that <code>int</code> size always be large enough to store the converted memory address of ANY TYPE being converted to <code>int</code>?</p>
<p><strong>EDIT:</strong>
Or is safer to use <code>long int</code> to avoid a possible loss of data?</p>
<p><strong>EDIT 2</strong>: Sorry people, to make this question more understandable the thing I want to find out here is the size of returned HEX value as a number, not size of int nor size of pointer to int but plain hex value. I need to get that value in in human-readable notation. That's why I'm using <code>reinterpret_cast</code> to convert that memory HEX value to DEC value. But to store the value safely I also need to fing out into what kind of variable to it: int, long - what type is big enough?</p>
|
c++
|
[6]
|
5,632,451 | 5,632,452 |
PHP global variable not found in functions
|
<blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/5492931/global-variables-in-php">Global variables in PHP</a> </p>
</blockquote>
<p>I have a PHP script someting like</p>
<pre><code>global $var1;
function func1() {
$var1->something(); // $var1 not found ... why?
}
</code></pre>
<p>must I do global $var1 in every function?</p>
|
php
|
[2]
|
3,829,481 | 3,829,482 |
how to submit the form in jquery to server side by escaping or bypassing the Validations that were set
|
<p>how to submit the form in jquery to server side by escaping or bypassing the Validations that were set </p>
|
jquery
|
[5]
|
844,112 | 844,113 |
Creating Objects out of the registry using C#
|
<p>So here is what I am trying to accompish. I have several logging keys in the Registry for each specific process.</p>
<p>I would like to make an object out of these when the program starts so I can access the values when I need, so basically they are preloaded.</p>
<p>Here is what I have got thus far my class:</p>
<pre><code>class LoggingInfo
{
//field data
private String LogName;
private int DailyFile;
// Constructors.
public LoggingInfo() { }
public LoggingInfo(String LogName, int DailyFile)
{
this.LogName = LogName;
this.DailyFile = LogDailyFile;
}
}
</code></pre>
<p>So how do I get the properties from the registry for say the LoggingInfo Object? In my main program do I need to pass anything in?</p>
|
c#
|
[0]
|
226,677 | 226,678 |
store html(result) in variable and check if it equals a certain string with jquery
|
<p>I have this jquery code: </p>
<pre><code>var response = $("div.callbacktwo").html(result);
if (response == 'Added!'){
//some code here
}
</code></pre>
<p>Unfortunately, this does not work. I want to check if "Added!" is in the callback. Any ideas?</p>
|
jquery
|
[5]
|
410,164 | 410,165 |
How to get gmail username into asp.net page
|
<p>Hello folks when someone login to gmail account and in another tab he open google.
Then you must have seen gmail username displays at the top right corner of the google.
I want the same functionality into my asp.net website. I have searched a lot but could not find any answer. please help if anybody have any idea about it. </p>
|
asp.net
|
[9]
|
5,812,016 | 5,812,017 |
how to call url of any other website in php
|
<p>how to call url of any other website in php.</p>
|
php
|
[2]
|
1,625,190 | 1,625,191 |
What is the difference between these two prototypes?
|
<pre><code> 1. A a;
A b = a;
2. A a,b;
b = a;
</code></pre>
<p>What is the difference between these two operator =?</p>
<p>Does the first one needs a prototype?</p>
|
c++
|
[6]
|
3,963,282 | 3,963,283 |
How to make an EditText Box in android?
|
<p>I would like to make my application ask the user some informations via something similar to VB.NET's inputbox. How can I do this??? I don't want to have a permanent control on the screen, I just want to make it appear when I need it. Actually, just as an inputbox.</p>
|
android
|
[4]
|
3,445,799 | 3,445,800 |
Proper way to implement Android XML onClick attribute in Activity
|
<p>I have used the <a href="http://developer.android.com/reference/android/view/View.html#attr_android%3aonClick" rel="nofollow">android:onClick</a> attribute extensively in my XML layouts for my Android application.</p>
<p><strong>Example:</strong></p>
<pre><code><Button
android:id="@+id/exampleButton"
android:onClick="onButtonClick" />
</code></pre>
<p>Is it proper to create an Interface to enforce the implementation of those onClick methods in Activities that use that layout file?</p>
<pre><code>public interface MyButtonInterface {
public onButtonClick(View v);
}
</code></pre>
|
android
|
[4]
|
2,300,371 | 2,300,372 |
Array declared within main throws stack overflow, declared outside main does not
|
<p>I have the below code:</p>
<pre><code>#include<iostream>
#include<cstdio>
using namespace std;
int main(){
int pnp[2][105],fin[2][105];
int time[105],n,m,dummy,prod = 0;
int const maxvv = 2000000;
int d[maxvv];
return 0;
}
</code></pre>
<p>I get a stackoverflow at <code>int d[maxvv]</code>. However, if I shift to the global scope</p>
<pre><code>#include<iostream>
#include<cstdio>
using namespace std;
int const maxvv = 2000000;
int d[maxvv];
int main(){
int pnp[2][105],fin[2][105];
int time[105],n,m,dummy,prod = 0;
return 0;
}
</code></pre>
<p>I do not get this error. Can anybody tell me what is the difference. Using vs 2008 with c++ on windows 7</p>
|
c++
|
[6]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.