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,390,727
3,390,728
How to execute php file into variable?
<p>Does it possible to execute php file and store its output into some variable?</p> <p>For example i have one global template, then i need to process subtemplates, and afterall i need to insert that subtemplate output into global template block. </p> <p>How can i do it ?</p>
php
[2]
4,913,021
4,913,022
How can I change/modify a 3 level hierarchy
<p>I have a table in my database which keeps track of a 3 level hierarchy. What is the best way to display and change/modify this hierarchy? Which asp.net control to use and how?</p>
asp.net
[9]
1,334,397
1,334,398
All C# Syntax in a single cs file
<p>I heard about there being a cs file on the internet from a couple different sources that has all of the syntax in C# in a single file, which would be really good for a crash course to get ready for a job I have. Unfortunately no one could point me to the exact file, has anyone heard or seen anything like this?</p>
c#
[0]
5,891,732
5,891,733
How to utilize POWERVR™ SGX Series5 GPU from iPhone OS 4.0?
<p>POWERVR™ SGX Series5 GPU is embedded in Apple iPhone and I wonder how to utilize it (i.e. use it as low power GP-GPU) from iPhone OS 4.0?</p>
iphone
[8]
4,567,757
4,567,758
Updating numerous web clients periodically from the server
<p>G'Day,</p> <p>I am planning an ASP.NET 4 application. Not sure if it will be MVC3 or WebForms yet. I need to be able to perform the following:</p> <ul> <li>I have data coming into the the .NET assembly on the web server via a serial link</li> <li>I want to send this same data to all "connected" web clients</li> <li>I want to PUSH the changes from the server. NOT poll the server</li> </ul> <p>"Connected" you say? HTTP is a RESTful and there are no permanent connections. So I am guessing I need to open up a web socket or similar to do this? Ideally I would also like to know what page the connected client is on so that I don't send them data they wont need (assuming I have a correlation between what is being displayed and the data it concerns).</p> <p>Performance and scalability are obviously issues here. I don't foresee having more than 10 simultaneous clients in the intranet I am running on. However I would like to scale it larger and potentially include Internet connected clients.</p> <p>What are my options here? All suggestions and pointers greatly appreciated.</p>
asp.net
[9]
3,005,248
3,005,249
Writing a demo for snake game
<p>I've written a snake game in Java. What I also want to do is to create a demo for that (so snake would play by itself). I've written a simple demo, but snake dies pretty fast. So, is there any algorithms or something for that kind of problem? I believe it is a little bit similar to chess game problem? <strong>I want that snake would be alive as long as possible</strong>. Thank you.</p>
java
[1]
3,250,409
3,250,410
JavaScript Image constructor overload?
<p>A lot of scripts dynamically create images, such as</p> <pre><code> im = new Image(); im.src = 'http://...'; </code></pre> <p>I am looking for overloading of constructor for Image class with feature to add a reference of each newly created object to some array.</p> <p>Let's say I have</p> <pre><code> var dynImages = new Array; </code></pre> <p>And then I want each new dynamically created image to be in my <code>dynImages</code> array, so then I can anytime access <code>src</code> of each of image that was created by <code>new Image()</code> by <code>dynImages</code>.</p> <p>Possible?</p>
javascript
[3]
1,600,686
1,600,687
Getting error while retrieveing value from name
<p>I am beginner with jquery, I am getting error while getting input from name in jquery.. My code is... HTML</p> <pre><code>&lt;input type="text" name="pcpfname" id="pcpfname" class="text" /&gt; &lt;input type="submit" name="pcpsubmit" id="pcpsubmit" value="Submit" /&gt; </code></pre> <p>Jquery</p> <pre><code>$('#pcpsubmit').click(function(){ var pcpfname = $('input[name=pcpfname]'); alert (pcpfname); }); </code></pre> <p>My alert message is</p> <pre><code>[object Object] </code></pre>
jquery
[5]
5,832,606
5,832,607
How to set Grid images have uniform height and width
<p>Friend's I have a task to parse thumbnail images and to set it on grid view,where url image content to be in different height and width(some images to be 60*60, or 110*80),how can i set images in grid have uniform height and width.</p> <p>Thanks in advance.</p>
android
[4]
3,848,415
3,848,416
problem in delegate declaration and its invocation
<p>Hey, When I try to call the event <code>myevent</code> in the function <code>fire</code>, it gives compiler error as</p> <blockquote> <p>delegate mydelegate does not take 0 arguments.</p> </blockquote> <p>if i try to give arguments in calling myevent as</p> <pre><code>myevent(this); </code></pre> <p>it again shows error as it does not take 1 parameters. what parameters am i supposed to give in the calling <code>myevent</code>? Here's the program code:</p> <pre><code>namespace useofdelegates { public class Class1 { int i; public delegate void mydelegate(object sender,EventArgs e); public event mydelegate myevent; public void fire() { myevent(this); // *** shows compiler error *** } } } </code></pre>
c#
[0]
4,205,754
4,205,755
jQuery document ready has to be anonymous function?
<p>I wanted to isolate my initiation function, so as not to put an anonymous function inside the <code>$(document).ready()</code> function. But, when I define it separately, and then try to call it, it doesn't fire.</p> <p>An example:</p> <pre><code>function init () { alert('hello world'); } $(document).ready( init ); </code></pre> <p>But the alert never fires. Can someone explain this to me, please?</p>
jquery
[5]
1,271,546
1,271,547
Setting javascript defineGetter and defineSetter in a loop
<p>Why does each iteration of this:</p> <pre><code>var o = {}; var foo = [['a',1],['b',2],['c',3],['d',4],['e',5]]; for(var i = 0; i &lt; 5; i++) { o.__defineGetter__(foo[i][0], function() { return foo[i][1]; }); console.info(JSON.stringify(o)); } </code></pre> <p>Reset all previous assignments and output this:</p> <pre><code>{"a":1} {"a":2,"b":2} {"a":3,"b":3,"c":3} {"a":4,"b":4,"c":4,"d":4} {"a":5,"b":5,"c":5,"d":5,"e":5} </code></pre> <p>When what I expect / want to finish with is:</p> <pre><code>{"a":"1","b":"2","c":"3","d":"4","e":"5"} </code></pre> <p>How do I achieve what I want?</p>
javascript
[3]
1,538,331
1,538,332
Andorid: How to use ota to update firmware
<p><strong>Recently, i want to update touch firmware to my device by android ota, but i can't find any reference. Can Any one please tell me the steps about update firmware by ota ? Thank you !!</strong></p>
android
[4]
310,394
310,395
It is possible to auto send SMS for Android
<p>I am not sure if this question appropriate as I new to Android. I am thinking to solve a problem such that when I am driving I want my Android to Auto send or Auto reply any incoming SMS. Would appreciate if you can guide me or provide me some tutorial or code on this. Can this task be accomplished in Android? Thanks.</p>
android
[4]
4,026,060
4,026,061
Javascript: check if the url is changed or not?
<p>My url format is like : </p> <pre><code>http://domain.in/home http://domain.in/books/notes http://domain.in/books/notes/copy </code></pre> <p>I've called a javascript function on window.load to check if the url has changed or not.</p> <p>If the url has been changed then code is executed else it will return and checks again after 5 sec.</p> <p>My code is :</p> <pre><code>window.onload = function(){ setInterval(function(){ page_open(); }, 5000); }; function page_open(){ var pages=unescape(location.href); pages=pages.substr( pages.lastIndexOf("studysquare.in/") + 15 ); // gives book if url is http://studysquare.in/book //alert("pages"+pages+"\n\n recent"+recent); if (pages==recent) { return; } recent=pages; alert("Reached down now the code will execute."); } </code></pre> <p>The problem now is : when the url is like :</p> <pre><code>http://domain.in/book </code></pre> <p>Single level deep, then everything works fine. But when the url is like</p> <pre><code>http://domain.in/book/copy or http://domain.in/book/copy/notes </code></pre> <p>Then nothing works..... Any help to check 3 level deep url change in javascript every 5 sec ? :)</p> <p>Hi sorry I forgot to tell that... I've .htaccess file which doesnt allow to navigate the page when any length url after the <code>domain.in/</code> is written.... that means only single page remains open and not affected by the url change...</p>
javascript
[3]
2,971,976
2,971,977
Change millisec for window.setInterval function
<p>I used <code>window.setInterval</code> function. this function includes 3 arguments :</p> <pre><code>setInterval(code,millisec,lang) </code></pre> <p>I used that like this:</p> <pre><code>var counter = 1; window.setInterval(function() {}, 1000 * ++counter); </code></pre> <p>but when first time set timer (second argument), is not changed and that act Like below code:</p> <pre><code>window.setInterval(function() {}, 1000); </code></pre> <p>please write correct code for change timer</p>
javascript
[3]
1,923,056
1,923,057
SMack API in java
<pre><code>public void processMessage(Chat chat, Message message) { if (message.getType() == Message.Type.chat) System.out.println(chat.getParticipant() + " says: "+ message.getBody()); **processmsg** = message.getBody(); System.out.println("Message from Friend -----:"+**processmsg**); } </code></pre> <p>Hi.how to use this <strong>processmsg</strong> String in another method.if i use outside this method i get null value. plz reply soon</p>
java
[1]
3,301,989
3,301,990
how to pass query string in a multipage html document
<p>I have html document with 2 pages and am using html5, jquery and jquery mobile. I need to pass a value from onepage to another page. I am using url like test.html#page-b. How to pass query string through this url</p>
jquery
[5]
1,003,478
1,003,479
How to do multiple arguments to map function where one remains the same in python?
<p>Lets say we have a function add as follows</p> <pre><code> def add(x,y): return x+y </code></pre> <p>we want to apply map function for an array </p> <pre><code> map(add,[1,2,3],2) </code></pre> <p>The semantics are I want to add 2 to the every element of the array. But the map function requires a list in the third argument as well.</p> <p><strong>Note:</strong> I am putting the add example for simplicity. My original function is much more complicated. And of course option of setting the default value of y in add function is out of question as it will be changed for every call.</p> <p>Thanks a lot.</p>
python
[7]
1,358,296
1,358,297
jquery toggling more than one div
<p>i'm trying to make toggling div with only 1 javascript.</p> <p>I tried this, the first div does what it was meant to do but the second doesn't.</p> <p>Have a look.</p> <pre><code>&lt;body&gt; &lt;div&gt; &lt;div&gt;He &lt;div&gt;You &lt;div id="Me"&gt;&lt;a id="me"&gt;Me&lt;/a&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;div id="This"&gt;We &lt;/div&gt; &lt;/div&gt; &lt;div&gt; &lt;div&gt;1 &lt;div&gt;2 &lt;div id="Me"&gt;&lt;a id="me"&gt;3&lt;/a&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;div id="This"&gt;4 &lt;/div&gt; &lt;/div&gt; &lt;script&gt; $("#me").click(function () { $(this).parent().parent().parent().siblings("#This").slideToggle("slow"); }); &lt;/script&gt; &lt;/body&gt; </code></pre> <p>when i click me, we disappear, alright. But when i click 3, 4 doesn't disappear.</p>
jquery
[5]
2,855,909
2,855,910
Copy constructor versus Clone()
<p>In C#, what is the preferred way to add (deep) copy functionality to a class? Should one implement the copy constructor, or rather derive from <code>ICloneable</code> and implement the <code>Clone()</code> method? </p> <p><b>Remark</b>: I wrote "deep" within brackets because I thought it was irrelevant. Apparently others disagree, so I asked <a href="http://stackoverflow.com/questions/3350725/does-a-copy-constructor-operator-function-need-to-make-clear-which-copy-variant-i">whether a copy constructor/operator/function needs to make clear which copy variant it implements</a>.</p>
c#
[0]
3,784,691
3,784,692
python private method return value
<p>Im new to OOP and therefore I got one question. Say I got a simple class with one public and one private method. If I call the private method in the public method - should it return a value, or should that value be set as a field in my object eg:</p> <pre><code>class Test: def __init__(self, path): self.path = path def __getNoOfFiles(self): 'count files in self.path' return no_of_files def readDir(self) ... no_of_files = __getNoOfFiles() </code></pre> <p>or</p> <pre><code>class Test: def __init__(self, path): self.path = path self.no_of_files = 0 def __getNoOfFiles(self): self.no_of_files = 'count files in self.path' def readDir(self) __getNoOfFiles() no_of_files = self.no_of_files </code></pre>
python
[7]
432,122
432,123
popen not working correctly on sunos5
<p>I have program to find emacs path using <code>which command</code> if it does not find emacs then i find emacs in <code>$PATH</code> variable. Lets my system have emacs then below program is giving output correct <strong>but it is sourcing .cshrc file</strong> I dont know why?</p> <pre><code>/* getenv example: getting path */ #include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;iostream&gt; #include &lt;sys/stat.h&gt; using namespace std; int main () { FILE *fp; int status; char path[256]; const char *command = "which emacs 2&gt;&amp;1"; /* Open the command for reading. */ fp = popen(command, "r"); if (fp == NULL) { printf("Failed to run command\n" ); exit(0); } string path1; /* Read the output a line at a time - output it. */ while (fgets(path, sizeof(path)-1, fp) != NULL) { path1 += path; } cout&lt;&lt;"orignal path after which command = "&lt;&lt;path1&lt;&lt;endl; /* close */ bool found = true; std::string search="which:"; char *tmp; tmp = strstr(path1.c_str(),search.c_str()); if (tmp != NULL) { found = false; } else { found = true; } if (found){ cout&lt;&lt;"Found Emacs"&lt;&lt;endl; cout&lt;&lt;"path = "&lt;&lt;path1; string path2; for (int i=0; i &lt; path1.length()-1; i++) { path2 += path1[i]; } //path1[path1.length()-1]= " "; path2 += " -i"; cout&lt;&lt;"final path = "&lt;&lt;path2&lt;&lt;endl;} else cout&lt;&lt;"Not found Emacs"&lt;&lt;endl; pclose(fp); return 0; } </code></pre>
c++
[6]
3,570,215
3,570,216
How do I prevent/suppress SIGFPE in C++?
<p>I'm trying to convert a double to float as well as various integer types inside a dll, which is used as a Game Maker extension. I don't need a sensible result if the double doesn't fit the range of the target types, so I simply used a static_cast.</p> <p>Everything works as intended when I call this code from my own test C++ application, but when it's called from Game Maker, range errors raise SIGFPE for some reason, which leads Game Maker to terminate my program with an error message.</p> <p>I don't need sensible results for out-of-range conversions, but crashing is a no-no. I tried using llround instead of a cast, but it also raises the signal.</p> <p>I also tried catching the signal myself by using signal(SIGFPE, SIG_IGN); right before the conversion, but it didn't change the behaviour at all. Maybe the ominous comment in the mingw signal.h has something to do with that: "SIGFPE doesn't seem to work?"</p> <p>I checked the source code of a different dll used in a Game Maker extension, and the binary provided by the author performs simple cast conversions without a problem. When I compile the source myself however, the SIGFPE problem is present again. I am guessing that the author used a different compiler, but I'd prefer to stay with mingw if possible. </p> <p>So, how do I either perform these conversions safely, or prevent the signal from being generated when I perform them with a simple cast? I'm using mingw-g++ 4.5.0 to compile at the moment.</p> <p>Here's the function where the problem happens:</p> <pre><code>template&lt;typename ValueType&gt; static double writeIntValue(double handle, double value) { boost::shared_ptr&lt;Writable&gt; writable = handles.find&lt;Writable&gt;(handle); if(writable) { // Execution reaches this point ValueType converted = static_cast&lt;ValueType&gt;(value); // Execution doesn't reach this point if e.g. ValueType // is short and value is 40000 writable-&gt;write(reinterpret_cast&lt;uint8_t *&gt;(&amp;converted), sizeof(converted)); } return 0; } </code></pre>
c++
[6]
525,597
525,598
Stop duplicate messages being posted from submit button
<p>Hey basically just having a little trouble with the following, submitting a message from a textarea, and on clicking of the submit button the following runs... I need the button to be disabled or another way which stops the user from clicking the button several times and submitting the message over and over again. I think I know where I am going wrong below that it is disabling the button before it is submitting?. At the moment with the disabling code in, it disables the button but does not submit the message, if I remove it, it submits fine.</p> <pre><code>$("#leaguesubmit").click(function(){ if($('#messageinput').val().length &gt; 300 || $('#messageinput').val().length == 0 || $('#messageinput').val() == "Please enter your league message here..." ){ return false; }else{ $("#leaguesubmit").attr("disabled","disabled"); return true; } }); </code></pre>
jquery
[5]
3,598,899
3,598,900
Can I log in to my site from my iPhone app?
<p>I'm trying to make a log in or sign up feature for my web site in my iPhone app. My website is a content management system, and like any other CMS, it has log in and registration features. It also has permmissions, dependent on the user account. I think I would have to use <code>UIWebView</code> for this. </p> <p>Are there any examples or tutorials I can examine?</p>
iphone
[8]
5,797,550
5,797,551
PHP split array in hundreds
<p>I have an array that can hold up to several thousands of items.(usually around 5000 items). I need to split this array into hundreds and process them and then continue with the rest of items. So far i handle the whole array which is slow. My code is</p> <pre><code>foreach($result as $p){ $sqlQuery = mysql_query("INSERT INTO message_details(contact, message_id)VALUES('$p', $message_last_id)"); $last_id = mysql_insert_id(); $xmlString .= "&lt;gsm messageId=\"$last_id\"&gt;".$p."&lt;/gsm&gt;"; $cnt++; } </code></pre> <p>How can i process the items in the array in hundreds? Eg. 100, then 200, then 300 etc</p> <p>Best Regards, Nicos</p>
php
[2]
3,717,571
3,717,572
Good jQuery advocacy materials (videos) suitable for a manager?
<p>Can anyone recommend any particularly compelling propoganda (papers or even better, video) on jQuery that would be suitable for a manager who knows very little about the technology?</p> <p>My manager seems very reluctant to consider letting us use it, seeming to think it is yet another technology flavor of the month / flash in the pan.</p>
jquery
[5]
2,491,680
2,491,681
How to get group radio button Value using Code ingnitor in the controller
<p>I have two radio button </p> <pre><code>&lt;input tabindex="3" type="radio" name="gender" id="gender" value="M"&gt;Male&amp;nbsp;&lt;input tabindex="4" type="radio" name="gender" id="gender" value="F"&gt;Female </code></pre> <p>How to get group radio button Value using Code ingnitor </p> <pre><code>$this-&gt;input-&gt;post("gender"); </code></pre> <p>I want to retrieve selected radio button value as "M" or "F" In the controller side.</p>
php
[2]
4,181,943
4,181,944
Can a variable be used inside a function without a Global declaration inside that function
<p>CODE 1:</p> <pre><code>x=4 def func(): print("HELLO WORLD") y=x+2 print (y) print (x) # gives o/p as HELLO WORLD 6,4,4. func() print (x) </code></pre> <p>CODE 2:</p> <pre><code>x=4 def func(): print("HELLO WORLD") y=x+2 x=x+2 # gives an error here print (y) print (x) func() print (x) </code></pre> <p>In the first code, it is not showing any error, it's adding the <code>x</code> value to 2 and resulting back to <code>y</code> and it prints the o/p as <code>6,4,4</code>. But Actually as I learnt so for, it should point an error because I am not giving the global declaration for <code>x</code> variable inside the <code>func()</code>. But its not ponting any error but in <code>Code 2</code> it gives an error saying that <code>x referenced before assignment</code>.</p> <p>The question is can <code>x</code> can be used for the assignment of its value to other variables? Even it is not followed with global declaration?</p>
python
[7]
5,806,303
5,806,304
How do I install xampp on Windows Vista?
<p>I'm a new student of PHP. How can I install xampp on Windows Vista?</p>
php
[2]
5,200,085
5,200,086
how to run at the same time imageClick() and onTouchEvent()?
<p>I have this image in the xml (and others elements):</p> <pre><code> &lt;ImageView android:clickable="true" android:onClick="imageClick" android:id="@+id/Decena0" android:layout_width="120dp" android:layout_height="120dp" tools:ignore="ContentDescription" /&gt; </code></pre> <p>I want to run the two next methods when I press on the image and I don't lift my finger: First:</p> <pre><code>public void imageClick(View view) { //Implement image click function Log.e("Example", "Imagen clickada"); } </code></pre> <p>Second:</p> <pre><code>@Override public boolean onTouchEvent(MotionEvent event) { //Coordenadas int x = (int) event.getX(); int y = (int) event.getY(); switch(event.getAction()) { case MotionEvent.ACTION_DOWN: break; case MotionEvent.ACTION_MOVE; break; case MotionEvent.ACTION_UP: break; } return true; } </code></pre> <p>How I can do it? Because if I press on the image and lift my finger on the image, only runs the first method (I understand it perfectly), but if I press on the image and I don't lift a finger and move my finger, not running any method. If I click somewhere else where there is no image the second method work well.</p> <p>Thanks for all</p>
android
[4]
1,597,467
1,597,468
how can i prevent onbeforeunload from firing when a certain condition is met?
<p>i have a page on which i want to confirm if the user wants to leave. i have to confirm only when a certain condition is met so i wrote code like this</p> <pre><code>var back=false; back=//check if user pressed back button window.onbeforeunload = function (e) { alert(back); //this alerts true if(back==true) return false; //e.preventDefault; --this does not work too }; </code></pre> <p>but this does not work. i mean when i click on back button this onbeforeunload still fires and i still get the confirmation message even when i m returning false.Whats can be wrong? Thanks </p>
javascript
[3]
2,620,134
2,620,135
Android: Save array to app data
<p>is it possible to save an entire array (or even ArrayList) to the android app data?</p> <p>as far as I know you can only do stuff like putInt, putBoolean or putString.... but what about more complex data-types? is there a way to do that?</p> <p>or do I have to convert the whole array to a String first, and then parse it to an array again on load?</p>
android
[4]
4,257,467
4,257,468
How to make this function return more than 1 value?
<pre><code>public Solution getReferenceSolution(Problem p) { int personalityVal = 1; int templateNameVal = 0; ... Solution personality = getComponentFactory().constructSolution(personalityVal); Solution templateName = getComponentFactory().constructSolution(templateNameVal); ... return personality,templateName,..; } </code></pre> <p>Here is the original code for class Solution:</p> <pre><code>public class Solution extends Object implements java.io.Serializable, edu.indiana.iucbrf.feature.Featured, Comparable, edu.indiana.util.xml.XMLRepresentable { private FeatureKey firstFeatureKey; private FeatureCollection features; /** Creates new Solution. */ protected Solution() { } public Solution(FeatureCollection features, Domain domain) { this.features = features; } public boolean getIsReferenceSolution() { return features.getIsReferenceSolution(); } public void setIsReferenceSolution(boolean isReferenceSolution) { features.setIsReferenceSolution(isReferenceSolution); } public boolean equals(Object other) { return (this.compareTo(other) == 0); } } </code></pre> <p>Here is inside Domain class code:</p> <pre><code>public Solution[] getReferenceSolution(Problem p) throws UnsupportedOperationException { Solution result; if (!haveReferenceSolution) throw new UnsupportedOperationException("Domain.getReferenceSolution: A getReferenceSolution() method has not been specified for this domain. If its use is required, please specify one using setEquivalenceClasses() or by overriding Domain.getReferenceSolution()."); else { if (haveBooleanSolutionCutoff) result = findNearestEquivalenceClass(p).applyTo(p, booleanSolutionCutoff); else result = findNearestEquivalenceClass(p).applyTo(p); } result.setIsReferenceSolution(true); return result; //&lt;---- error over here! } </code></pre>
java
[1]
1,566,963
1,566,964
jquery issue, onmouse over event not working on new row
<p>I have an html table with a few rows, I have included a jquery function as</p> <pre><code>$('tr').mouseover(function() { $(this).addClass('row_over'); }); </code></pre> <p>so that on mouse over the css class of that particular row changes. then I have added one more row using jquery, but the mouse over function doesn't work on the dynamically added row, mouse over function works in all rows except this new one.</p> <p>Please help me to sortout this issue </p> <p>Thank you</p>
jquery
[5]
3,819,760
3,819,761
C++ interface inheritance problem
<p>Hey, i'm trying to create a c++ stomp client, my client constructor is :</p> <pre><code>Client(std::string &amp;server, short port, std::string &amp;login, std::string &amp;pass, Listener &amp;listener); </code></pre> <p>it gets a listener object which when Listener is the following interface :</p> <pre><code>class Listener { virtual void message(StmpMessage message) =0; }; </code></pre> <p>now i attempt to instantiate a client in a test class :</p> <pre><code>class test : public virtual Listener { public: void message(StmpMessage message) { message.prettyPrint(); } int main(int argc, char* argv[]) { Client client("127.0.0.1", 61613, *this); return 0; } }; </code></pre> <p>i'm sending this to the client because this is a listener object, i get the following error :</p> <pre><code>/Users/mzruya/Documents/STOMPCPP/main.cpp:18: error: no matching function for call to 'Client::Client(const char [10], int, test&amp;)' /Users/mzruya/Documents/STOMPCPP/Client.h:43: note: candidates are: Client::Client(std::string&amp;, short int, std::string&amp;, std::string&amp;, Listener&amp;) /Users/mzruya/Documents/STOMPCPP/Client.h:37: note: Client::Client(const Client&amp;) </code></pre>
c++
[6]
1,533,944
1,533,945
When changing the href attribute of a link using jQuery, how do I reference the current href attribute?
<p>I'm trying to change the href attribute of links on my page. I need the bulk of the url to remain the same but just change a parameter. I've got this so far:</p> <pre><code>$("a[href*='/new_note?']").attr('href', function() { return this.replace(/date1=[\d-]+/, "date1=" + $("[name='new_date1']").val()); }); </code></pre> <p>but I'm getting this error:</p> <pre><code>this.replace is not a function </code></pre> <p>What am I doing wrong? Thanks for reading.</p>
jquery
[5]
1,219,556
1,219,557
JQUERY CSS Background
<p>I currently have a DIV with a background image set as follows:</p> <pre><code>background: url(../images/site/common/body-bannar-bkground.png) repeat 0 0; </code></pre> <p>How can I remove this image and set a background-color only:</p> <pre><code>background-color: #C1A3A5 </code></pre> <p>I know I can use JQUERY To set the new color like this</p> <pre><code>$('div#id').css('backgroundColor', '#C1A3A5'); </code></pre> <p>but when I do this the background image is still in place. How can I knockout the background image? I also need to do this in reverse so how can I knock out the background-color?</p> <p>Finally - would I be better to addClass() removeClass with the attributes set there or is basically the same factor?</p> <p>thx </p>
jquery
[5]
1,209,052
1,209,053
Bluetooth simply application
<p>I want to ask you about some bluetooth library which I can use to implement simply application. I want to connect two devices by bluetooth. In application I want to have two buttons and I want to send from one device to second device by bluetooth which button was push. How I can do that? Any idea or tutorials can recommend me?</p>
android
[4]
1,846,542
1,846,543
JavaScript Namespace Declaration
<p>I created a javascript class as follow:</p> <pre><code>var MyClass = (function() { function myprivate(param) { console.log(param); } return { MyPublic : function(param) { myprivate(param); } }; })(); MyClass.MyPublic("hello"); </code></pre> <p>The code above is working, but my question is, how if I want to introduce namespace to that class.</p> <p>Basically I want to be able to call the class like this:</p> <pre><code>Namespace.MyClass.MyPublic("Hello World"); </code></pre> <p>If I added Namespace.MyClass, it'll throw error "Syntax Error". I did try to add "window.Namespace = {}" and it doesn't work either.</p> <p>Thanks.. :)</p>
javascript
[3]
1,974,168
1,974,169
selecting images in javascript
<p>I dont know javascript very well, I want to ask how to select images and show them on my screen. I want to make a list of images, then I will choose one of them and when I press a button show I want to demonstrate it. Is it possible in js?</p>
javascript
[3]
3,786,858
3,786,859
How to use another layout id?
<p>In my application I have used one alert box.. In this alert box, I give another layout to be show.. using <code>setView()</code> method.. I have a problem. How to use layout elements id in my activity?</p> <pre><code>LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); View layout = inflater.inflate(R.layout.volume, null); builder.setTitle("Volume"); builder.setView(layout); builder.setPositiveButton("OK", null); builder.setNegativeButton("Cancel", null); AlertDialog alert1 = builder.create(); alert1.show(); </code></pre>
android
[4]
4,645,920
4,645,921
Requests with JS - is this out dated?
<p>I am making a basic live chat and was wondering if i have learnt this correctly...</p> <p>I have my call function like this:</p> <pre><code>function call_data(url,data) { if (window.XMLHttpRequest) { AJAX=new XMLHttpRequest(); } else { AJAX=new ActiveXObject("Microsoft.XMLHTTP"); } if (AJAX) { querystring = "?dta="+data; AJAX.open("GET", url + querystring, false); AJAX.send(null); return AJAX.responseText; } else { return false; } } function checker(id){ result = parseInt(call_data('check_chat.php',id)); //check new messages if(result){//if new message loadchat(id); //load the messages } else { setTimeout(function() { checker(id); }, 5000); //check for new message every 5 seconds } } </code></pre> <p>Is this the best way to call for new messages periodically ?</p>
javascript
[3]
2,609,675
2,609,676
Video 'Snipping' Android - Possible?
<p>Hey guys, I'm looking into creating an application that requires a video file taken on the mobile phone, open it and allow the user to cut the video using two sliders, one for IN(the beginning) and the other for out(end of the clip you want), this will then create a new file and my app will use it then.</p> <p>Does this sound feasible? Where should I start looking in order to do this quite simple concept? Does anyone have any ideas?</p> <p>Thanks</p>
android
[4]
46,558
46,559
Update textview from onPostExecute in AsyncTask
<p>I have a textview that i would like to update each time my asynctask is complete.</p> <p>But from what ive read so far it can only be done in <code>onPostExecute</code> if you use <code>setContentView()</code> before. But since i dont know which view the user is currently in when the task completes, it doesnt sound like a good solution to me. And even if i can get the current view, woudlnt <code>setContentView()</code> redraw the view?</p> <p>Thanks</p>
android
[4]
945,701
945,702
php greater than number decimal number without round, ceil, floor
<p>Interesting problem I have here, usually I just round up/down respectively for my needs with numbers but today I find myself having to be very specific. I am working on a project of which has many dot versions. Its a web based app, with a client side application, of which a new feature is coming out where in the software if your version of the client is 2.3 or greater then the new feature is avaliable in the app, if not, then it needs to be hidden away. So I am trying</p> <pre><code>if($version &gt;= 2.3){/*code to show*/} </code></pre> <p>which doesnt appear to be working with the decimal based number, is there a work around that anyone knows of that doesn't involve rounding it in either direction?</p>
php
[2]
5,476,966
5,476,967
Convert System.Drawing.Image to format(.jpeg .gif) whitout saving
<p>I need to convert a System.Drawing.Image object to gif whitout saving it to a file(that means i can't use the save function). (bitearray or base64) sow i can send it to a web service. the code is on a server and i don't have write permisssion on it. c# code.</p>
c#
[0]
5,460,850
5,460,851
Return 1 of 3 values using 2 flag variables as conditions
<p>I need to return 1 value... either e.next_arr, e.next_dept, or e.next_checkout. </p> <p>There are two flags, f1 &amp; f2. f1 is true if the multiset ( customers picking groceries ) is not empty, and f2 is true if the queue ( customers waiting to checkout ) is not empty.</p> <p>I know that if the queue is full, you shouldnt return e.next_dept because theres nobody waiting, and you shouldnt return e.next_checkout if the multiset is empty because theres nobody picking groceries...</p> <p>I cannot figure out the logic to return the lowest of the three values, with regards to the flags.</p> <p>Here is my method definition..</p> <pre><code>int update_clock ( const event&amp; e, const bool&amp; f1, const bool&amp; f2 ) { } </code></pre>
c++
[6]
5,320,530
5,320,531
How to twit a picture with some text in iPhone
<p>I want to know that is there any way I can post picture in twitter with some text, some one has suggested to use "http://tinyurl.com/".I don't know where to start, in my previous application I twit successfully but that only contains text. A proper direction to proceed would be a great help.</p>
iphone
[8]
2,094,845
2,094,846
Garbage collection of referenced objects in Java
<p>I have the following code:</p> <pre><code>class Test { public static void main(String[] args) { String a,b,c; a = new String(args[0]); b = a; a = null; b = null; } } </code></pre> <p>Can someone tell me when a will be eligible for garbage collection. I think it's after b is made null because don't a and b reference the same object ?</p>
java
[1]
5,392,903
5,392,904
Trouble with reading file
<p>In my app I have to set one password from a settings page and write it to a file, After that when i enter into the home page i have to read that file if the file is null i have to enter to the settinngs page,</p> <p>The code used for it is.....</p> <pre><code> try { System.out.println("Enter try block!!!"); FileInputStream fis = openFileInput(FILENAME1); InputStreamReader in = new InputStreamReader(fis); BufferedReader br = new BufferedReader(in); data = br.readLine(); System.out.println("data from settings file"+data); System.out.println("-------1Data Read From File is:1" + data); if(data.equals(null)) { Toast.makeText(getApplicationContext(), "You have to set a password", Toast.LENGTH_SHORT).show(); Intent in1 = new Intent(); in1.setClass(getApplicationContext(), SetteingsPage.class); startActivity(in1); } } catch (Exception e) { } </code></pre> <p>If the password is already set,Then the code is working properly..But if it is null it is not entering into settings class...</p>
android
[4]
4,644,911
4,644,912
access t9 predictive text input engine on Android phones
<p>I was wondering it there is an API that can access the core functionality of t9 predictive text engine on Android phones. The API should have some access point like: -setCurrentLanguage -closeCurrentLanguage -appendKey(some key) For example: appendKey(4),appendKey(6),appendKey(6),appendKey(3) will give: "good" -get current word -get next candidate -get previous candidate etc... In Symbian it is called CPtiEngine.</p> <p>Thanks for help</p>
android
[4]
1,745,099
1,745,100
how do I retrieve an image from my resx file
<p>I have added an image to my forms resource file myForm.resx and I would like to use it in my code file myForm.cs, but I am not entirely clear on how to get a handle to it.</p>
c#
[0]
1,733,216
1,733,217
Android list view on click
<p>i have a list view with 15 items. when i click on any item i want to change the screen(Intent). how can i change the activity on item selected in android? any tutorial or source code?</p> <p>thanks in advance.</p>
android
[4]
900,989
900,990
android, int to string?
<p>I get the id of resource like so:</p> <pre><code>int test = (context.getResourceId("raw.testc3")); </code></pre> <p>I want to get it's id and put it into a string. How can I do this? .toString does not work.</p>
android
[4]
1,460,829
1,460,830
Javascript selecting part of a string and converting it to uppercase
<p>I have a string like this:</p> <pre><code>A sampletext b sampletext3 c exampletext A sampletext587 b sampletext5 b sampletextasdf d sampletext4 b sometext c sampletextrandom </code></pre> <p>How do I, in JS, convert all the text on the lines starting with <code>b</code> to upper case?</p> <p>Thanks!</p>
javascript
[3]
2,674,368
2,674,369
Calling a changing function name on an object with PHP : how?
<p>How would I do something like this :</p> <pre><code>class Test { public function test($methodName) { $this-&gt;$methodName; } private function a() { echo("a"); } private function b() { echo("b"); } } $testObj = new Test(); $testObj-&gt;test("a()"); $testObj-&gt;test("b()"); </code></pre> <p>Maybe I should just pass a parameter "TYPE" and use a "IF statement" but I'm just curious! :)</p> <p>And what if the "dynamic function name" has one or more parameters? </p> <p>UPDATE : Thanks everyone! :)</p> <p><strong>UPDATE #2 - Answer :</strong> </p> <pre><code>class Test { public function testOut($methodName) { $this-&gt;$methodName(); } private function a() { echo("a"); } private function b() { echo("b"); } } $testObj = new Test(); $testObj-&gt;testOut("a"); $testObj-&gt;testOut("b"); </code></pre> <p>The problem with the class is that there was a method named "Test" (the same as the class name)... I changed it and it worked.</p>
php
[2]
2,572,864
2,572,865
schedular in windows service
<p>I had written one windows service in C#.NET which fires on every miniutes... I want to fire a mail to my manager in every month on say xyz date.... this task shld repeted on every month on same date... So can any one tell me how to do this..? I mean to say the block of code which i will write shld get executed on same date of every month...</p>
c#
[0]
5,067,736
5,067,737
Error with code.. Please check it out
<p>I have two tables and I want to show a list items of particular table as hyperlink only if its value exist in another table. Otherwise it show value as plain text not hyperlink.</p> <p>Considering example...</p> <pre><code>$result= mysql_query("select * from tbl_songlist_info order by song_title") or die(mysql_error()); $resultpoet= mysql_query("select * from tbl_poet_info") or die(mysql_error()); $rowpoet= mysql_fetch_array($resultpoet); while($row = mysql_fetch_array($result)) </code></pre> <p>Now I have to show values of <code>$row</code> as hyperlink only if its value exist in <code>$rowpoet</code>.. I have used in array function. please chk it out...</p> <pre><code>&lt;? if (in_array($row['poet_name'],$rowpoet)) { ?&gt; &lt;a href="poet.php?title=&lt;?=$row['poet_name'] ?&gt;"&gt;&lt;? } ?&gt; &lt;?=$row['poet_name'] ?&gt; &lt;/a&gt; </code></pre> <p>please check this code. All value are showing as plain text if value exist in other table than also...</p>
php
[2]
5,831,699
5,831,700
How set a view transparent?
<p>I have a class MyView that heritates from View (used to draw on it). I want to put an image on the background and still be able to draw. Nothing basic works si far Does any one have a solution?</p> <p>thanks</p> <pre><code>public class MyView extends View {....} </code></pre> <p>in the main actvity : </p> <pre><code>MyView vueDraw = (MyView)findViewById(R.id.vueDraw); </code></pre>
android
[4]
4,692,464
4,692,465
how to compare a set of characters with a map which keys are characters?
<p>If i have a set of characters which is called characters and contains the following Characters (doesn't have to be SortedSet) </p> <pre><code>'c''h''a''r''a''c''t''e''r' </code></pre> <p>and i have a map which has sets of charcters as its keys and strings as values for example</p> <pre><code>map&lt;Set&lt;Character&gt;&gt;,&lt;String&gt; aMap = new HashMap&lt;Set&lt;Character&gt;&gt;,&lt;String&gt;(); aMap.put('a''h''t', "hat"); aMap.put('o''g''d', "dog"); aMap.put('c''r''a''t''e', "react"); </code></pre> <p>What javdoc method would i use to compare the characters since they are both in a Set, then to iterate through the keySet using a for loop to compare the characters to find only the keys that are made from charcters that are contained within the first. So in above example the second entry ('o''g''d', "dog") would be ommitted. </p> <p>thanks</p> <p>andy</p>
java
[1]
986,286
986,287
A curious C# syntax with a question mark
<pre><code>private enum E_Week { Mon = 0, Tue, . . . } </code></pre> <p>What does the following code mean?</p> <pre><code>E_Week? week= null; </code></pre> <p>Is it equal to the following code? What is the function of the '?' sign here?</p> <pre><code>E_Week week= null; </code></pre>
c#
[0]
482,384
482,385
animation in iphone
<p>I am looking for some reference about the animation such that when you click on the application, it will bring you the first screen but slowly. </p> <p>Does anybody know what it is please advice me on this issue. Thanks</p> <p>edit I just wanna make a nice transition after all.Whenever I click on the application, the first screen just come up. I would like to make it nicer just like the first screen is brought slowly slowly and displayed on the scree. Hope it makes sense now.</p>
iphone
[8]
2,340,218
2,340,219
How to pass this variable to this function?
<p>I have to pass <strong>aaa</strong> to <strong>ehi()</strong> function in the <strong>mitt</strong> parameter.</p> <p><strong>aaa</strong> is an array of numbers like: 29837,127365,5645,12323,47656564,2312,4534,2343</p> <p>This is the correct way that the <strong>ehi()</strong> works:</p> <pre><code> function ehi(aaa) { love({functionality: 'kiss', mess: 'yuhuuuuuu', mitt: '29837,127365,5645,12323,47656564,2312,4534,2343' }); } </code></pre> <p>I need to substitute 29837,127365,5645,12323,47656564,2312,4534,2343 with aaa.</p> <p>How can I do that ?</p>
javascript
[3]
3,462,865
3,462,866
SignalStrength values: what's the difference between cmda and evdo?
<p>On a Verizon phone, a Motorola Droid X2, if I get the signal strength with a SignalStrength object and look at its values, both the cdma and evdo values appear valid. </p> <p>If I print out a signalStrength.toString(): </p> <pre><code>09-09 11:48:00.678: INFO/ConnectionStatusAndroid::onSignalStrengthsChanged(4773): *** Signal Strength:SignalStrength: 99 -1 -87 -70 -63 -1 5 cdma 0 0 0 0 0 0 </code></pre> <p>If the phone gives out apparently valid values for both cdma and evdo, then what's the difference? </p>
android
[4]
898,634
898,635
PHP how to explode string into groups of 6 letters in array
<pre><code>$string = 'billiejeanisnotmylover'; $array = some_function($string,6); $array[0] = 'billie' $array[1] = 'jeanis' $array[2] = 'notmyl' $array[3] = 'over' </code></pre> <p>do you have an idea what some_function would be?</p>
php
[2]
621,785
621,786
Whitespace converted to rectangle
<p>When I copy the first paragraph of this page from my browser to a notepad which is under (محمد بصل), I see whitespaces replaced with rectangles in my notepad: <a href="http://www.shorouknews.com/news/view.aspx?cdate=03092012&amp;id=73df0e96-a9d8-44a1-83a8-77b0daf314a7" rel="nofollow">http://www.shorouknews.com/news/view.aspx?cdate=03092012&amp;id=73df0e96-a9d8-44a1-83a8-77b0daf314a7</a> How can I convert this in C# code to be inserted properly as whitespace in a SQL Server table? Thanks.</p>
c#
[0]
3,578,629
3,578,630
Find function and line number where variable gets modified
<p>Let's say that at the beginning of a random function variable $variables['content'] is 1,000 characters long.</p> <p>This random function is very long, with many nested functions within.</p> <p>At the end of the function $variables['content'] is only 20 characters long. </p> <p>How do you find which of nested functions modified this variable?</p>
php
[2]
5,638,615
5,638,616
initialisation list in c++
<p>I barely know c++.Not an expert.</p> <p>I am looking through an already existing code. I could not able to understand this following code.</p> <pre><code>typedef enum { eEvent_MsgOk, eEvent_InvalidMsgId, eEvent_Failure, } eEventType; class Rs232Event { public: Rs232Msg* m_pMsg; eEventType m_eEvent; } Rs232Event::Rs232Event(eEventType eEvent,Rs232Msg* pMsg) : m_pMsg(pMsg), m_eEvent(eEvent) { // not implemented on purpose } </code></pre> <p>Here using the initialisation list they are intialising the values.</p> <p>But the Rs232Msg class doesnt have a single parameterised constructor.</p> <p>But its having a constructor which accepts 4 parameters.</p> <p>I could not identify how its getting invoked.But the code runs without any error.</p>
c++
[6]
3,821,868
3,821,869
insert into mysql problem
<p>i have a field in table opt named confirm of type tinyint. i want to insert value(1) by this statement but it is not working can any one help??</p> <pre><code>$connect= mysql_connect("localhost","root") or die ("Sorry, Can not connect to database"); mysql_select_db("login") or die (mysql_error()); $user=$_POST['staff']; echo $user; $query="SELECT * from users where username='$user' "; $result=mysql_query($query,$connect) or die(mysql_error()); $row=mysql_fetch_array($result); $uid=$row['userid']; echo $uid; $query="SELECT * from opt where userid='$uid' "; $result=mysql_query($query,$connect) or die(mysql_error()); $row=mysql_fetch_array($result); if($row['confirm']==0) { $query = "INSERT INTO opt (confirm) values(1)"; echo 'The user selected options has confirmed'; } ?&gt; </code></pre>
php
[2]
3,140,379
3,140,380
C# merge two objects together at runtime
<p>I have a situation where I am loading a very unnormalized record set from Excel. I pull in each row and create the objects from it one at a time. each row could contain a company and / or a client.</p> <p>My issue is that multiple rows could have the same objects, so I may have already created it. I do a comparison to see if it is already in the list. If so I need to merge the two objects to ensure I have not gained any new information from the second row.</p> <p>so:</p> <pre><code>company - client - address - phone ---------------------------------------- mycompany - - myaddress - mycompnay - myclient - - myphone </code></pre> <p>so the first row would create a company object with an address of "myaddress". The second row would create another company object (which by my rules is the same company as the name is the same), this also having a client reference and a phone number.</p> <p>So I would know they are the same but need to ensure all the data is merged into one object.</p> <p>At the moment I am creating a utility class that takes both objects, (one being the primary and the other to be merged, so one has priority if there is a clash), it goes through each variable and assigns the values if there are any. This is a bit boiler plate heavy and I was hoping there might be some utility I could utilize to do the manual work for me.</p> <p>The example has been simplified as there are a fair few other variables, some basic types and others that are more complex items.</p>
c#
[0]
5,978,751
5,978,752
Android home screen like navigation in view flipper
<p>I am using <code>ViewFlipper</code> to navigate between screens. Each screen has 4 images in a grid. How to have similar functionality that is present on android <code>home screen</code> and <code>application menu screen</code> where user can quickly navigate to a page by pressing circle shaped buttons on top of screen. What I should use to have this effect? Thanks in advance.</p> <p><img src="http://i.stack.imgur.com/k1SvY.png" alt="enter image description here"></p>
android
[4]
1,656,814
1,656,815
C++ function using reference as param error
<pre><code>struct node { string info; node *next; node() { info = "string"; next = NULL; } }; void insert(node &amp;anode) { node newNode; anode.next = &amp;newNode; } </code></pre> <p>What is wrong with this implementation of insert for this structure ? How should I fix this? <strong>added:</strong> Very sorry that I wasn't clear. I know what is wrong with the program. I want to know how I can insert a new node to a reference node. Since I am using a reference to a node as a param this mean that node must not be a pointer? So its stored on stack? which means I can't use memory from heap? (or else seg fault?) so how am I suppose to use new ? This is my main confusion. Perhaps my approach is wrong but I don't see why it should be.</p>
c++
[6]
4,386,937
4,386,938
How to display Posts in a Forum Web application using ASP .net C#
<p>I am developing a Forum Web Application using ASP .Net 3.5</p> <p>I am facing issues in displaying Posts and replies under a selected question. What display control shall I use in order to display the replies in separate boxes with comment date and user id in them ? (taking into account that Gridview is a Big NO)</p>
asp.net
[9]
5,098,544
5,098,545
Run time error while using realloc: " _CrtIsValidHeapPointer(pUserData), dbgheap.c"
<p>The following code is written in C++ but using realloc from stdlib.h because I don't know much about std::vector.</p> <p>Anyway, I get this weird run time error " " _CrtIsValidHeapPointer(pUserData), dbgheap.c".</p> <p>If you would like to see the whole method or code please let me know.</p> <p>I have 2 classes, Student and Grades. Student contains </p> <pre><code>char _name[21]; char _id[6]; int _numOfGrades; int* _grades; float _avg; </code></pre> <p>and Grade simply contains </p> <pre><code>Student* _students; int _numOfStudents; </code></pre> <p>while the following works </p> <p><code>_grades = (int *)realloc(_grades,(sizeof(int)*(_numOfGrades+1)));</code></p> <p>this will create that weird run time error:</p> <pre><code>_students = (Student *)realloc(_students,(sizeof(Student)*(_numOfStudents+1))); </code></pre> <p>Both _grades and _students are created with new with no problem at all. The problem is only while trying to realloc _students.</p> <p>Any input will be welcome.</p>
c++
[6]
4,239,730
4,239,731
How could i use The array texture in another class?
<p>I need to be able to use the variables in the array texture[] (wich is located int the Textures class) in the Board class. But I cant figure out how I would go about doing that.</p> <p>This is just me trying to figure out how to add Textures to things in java, i am attempting to learn how to make games. So im very noobish haha.</p> <p>This is the Class that i want to use the texture[] array in.</p> <pre><code>import java.awt.Color; import java.awt.Font; import java.awt.Graphics; import java.awt.Image; import javax.swing.ImageIcon; import javax.swing.JPanel; public class Board extends JPanel{ public Board(){ } public void paint(Graphics g){ g.drawImage(texture[1], 0, 0, null); g.setFont(new Font("Verdana", 0, 50)); g.setColor(Color.YELLOW); g.drawString(": FPS", 20, 50); } public void update(){ repaint(); } } </code></pre> <p>This is the class that creates the texture[] array.</p> <pre><code>import java.awt.image.BufferedImage; import java.io.IOException; import java.net.URL; import javax.imageio.ImageIO; import javax.swing.ImageIcon; public class Textures { BufferedImage img; private int w, h; public int id[]; public Image texture[]; public Textures() throws IOException { URL url = this.getClass().getResource("Resources/Textures.png"); img = ImageIO.read(url); w = 0; h = 0; for(int i1 = 0; i1 &lt; 16; i1++){ texture[i1] = img.getSubimage(w, h, 16, 16); id[i1] = i1; w += 16; h += 16; } } } </code></pre>
java
[1]
524,547
524,548
How to Rotate different data in days of the week in php
<p>I am working on a project in which i have to distribute different ad's per day, the ad's in form of array are:</p> <pre><code>$ad = array( 'attribute1_value' =&gt; "12", 'attribute2_value' =&gt; "xyz", 'attribute3_value' =&gt; 'http://example.com', 'attribute4_value' =&gt; 'data'); </code></pre> <p>The logic i am using with switch case :</p> <pre><code>$day = date('w',time()); switch ($day) { case '0': if($day == '0') { $count = 0; echo $ad; $count++; } else { $count = 7; echo $ad; } break; case '1': if($day == '1') { $count = 1; echo $ad; $count++; } else { $count = 8; echo $ad; } break; </code></pre> <p>Problem is if i have ~15 ad's then i want to distribute ad/day, date('w') output's the present day but after day 7 i.e saturday, on sunday ad number 8 initiate. I have to implement this scenario using date function. Also i have to send ad's to those user who are not experience this ad before. I am not expert in php, as a beginner working in php/mysql. Kindly help me to improve this concept</p>
php
[2]
4,452,401
4,452,402
"nice" keyword in c++?
<p>So I was doing some simple C++ exercises and I noticed an interesting feat. Boiled down to bare metal one could try out compiling the following code:</p> <pre><code>class nice { public: nice() {} }; int main() { nice n; return 0; }; </code></pre> <p>The result is a compilation error that goes something like this:</p> <pre><code>&lt;file&gt;.cpp: In function ‘int main()’: &lt;file&gt;.cpp:11: error: expected `;' before ‘n’ &lt;file&gt;.cpp:11: warning: statement is a reference, not call, to function ‘nice’ &lt;file&gt;.cpp:11: warning: statement has no effect </code></pre> <p>And this was using regular g++ on Max OS X, some of my friends have tried in on Ubuntu as well, yielding the same result.</p> <p>The feat seems to lie in the word "nice", because refactoring it allows us to compile. Now, I can't find the "nice" in the keyword listings for C++ or C, so I was wondering if anyone here had an idea?</p> <p>Also, putting</p> <pre><code>class nice n; </code></pre> <p>instead of</p> <pre><code>nice n; </code></pre> <p>fixes the problem.</p> <p>P.S. I'm a relative C++ newbie, and come from the ActionScript/.NET/Java/Python world.</p> <p><strong>Update:</strong></p> <p>Right, my bad, I also had an</p> <pre><code>#include &lt;iostream&gt; </code></pre> <p>at the top, which seems to be the root of the problem, because without it everything works just fine.</p>
c++
[6]
4,255,858
4,255,859
image management code?
<p>two days back i ask a question for image management, i get some reference that is 4guys the code is working fine i want to store that manged image in a folder but i not understand how can i save, can u help me. this is my code.....</p> <pre><code>public partial class Default2 : System.Web.UI.Page { public bool ThumbnailCallback() { return false; } protected void Page_Load(object sender, EventArgs e) { System.Drawing.Image.GetThumbnailImageAbort dummyCallBack = default(System.Drawing.Image.GetThumbnailImageAbort); dummyCallBack = new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback); System.Drawing.Image fullSizeImg = default(System.Drawing.Image); fullSizeImg = System.Drawing.Image.FromFile("C:\\05.jpg"); System.Drawing.Image thumbNailImg = default(System.Drawing.Image); thumbNailImg = fullSizeImg.GetThumbnailImage(100, 100, dummyCallBack, IntPtr.Zero); } } </code></pre>
asp.net
[9]
2,180,409
2,180,410
How do we use SqlDataReader obejct as an array?
<p>It might sound kiddish or silly but i wanna know that in codes like..</p> <pre><code>SqlDataReader rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection); rdr.Read(); Response.Write(rdr[1]. ToString()); </code></pre> <p>how do we use the <code>SqlDataReader</code> object as an array <code>(rdr[1])</code> without declaration?</p> <p>What I want to know is, what is happening in the following line?</p> <pre><code>Response.Write(rdr[1].ToString()); </code></pre> <p>Since rdr is an object, how art we able to use square brackets with that?</p>
asp.net
[9]
4,136,219
4,136,220
Java Old JRE Installation Issue
<p>At my company, we have an internal application that uses Java. It evidently must use 7.0.5, since the app stops working on machines that have been upgraded to 7.0.7. We have an installer stored on the network here that I was not initially notified about. Here's the situation.</p> <ul> <li>Two identical machines: "Laptop A" and "Laptop B"</li> <li>I downloaded a copy of jre-7u5 from oldversion.com and installed it on Laptop A.</li> <li>Java doesn't run in firefox on Laptop A (according to javatester.org as well as oracle's java site). I have set extensions.blocklist.enabled to "false", and plugins.hide_infobar_for_outdated_plugin to "true"</li> <li>I found out about the installer we already had before getting to Laptop B. Seeing as it was already on the NAS, I used it to install on Laptop B, and it works fine. I have uninstalled java on Laptop A, and reinstalled using our "known good" installer, to no avail. </li> </ul> <p>Is there any way I can resolve this? If not, the laptop can be requisitioned for another department, which doesn't use our custom app, but it would be best if I could get it going.</p>
java
[1]
607,914
607,915
how to implement dropbox in android application with REST API
<p><a href="https://www.dropbox.com/developers/docs" rel="nofollow">https://www.dropbox.com/developers/docs</a> is the best place, But I cannot get the proper answer, I want to implement dropbox in my android application with REST api, I don't want User Log in screen, want to put username and password dynamically.</p> <p>Any idea or code snippet for this Question? Thanks. </p>
android
[4]
3,757,629
3,757,630
Scanner error Symbol not found
<p>I have imported the java class but i keep getting this error with the following code</p> <p>Error: C:\Users\xiangzheng\Desktop\passoff\P70.java:51: error: cannot find symbol String a = scanner.next;</p> <p>Code: </p> <pre><code>Scanner scanner = new Scanner(sentence); scanner.useDelimiter(" "); String a = scanner.next; </code></pre>
java
[1]
5,399,086
5,399,087
Can i use this statement
<p>i this a valid command</p> <pre><code>$fp = fopen($hyphen + ".html","w"); </code></pre> <p>I have declared $hyphen already.But it doesn't seem to be working</p>
php
[2]
462,996
462,997
How to get value at a specific index of array In JavaScript?
<p>I have an array and simply wants to get the element / value at index 1 </p> <pre><code>var myValues = new Array(); var valueAtIndex1 = myValues.getValue(1); // (something like this) </code></pre> <p>How can I get the value at the 1st index of my array in JavaScript?</p> <p>Thanks</p>
javascript
[3]
2,096,724
2,096,725
How can I define my return type
<p>I have the following code:</p> <pre><code> public IList&lt;Content.Grid&gt; GetContentGrid(string pk) { // How can I define result to hold the return // data? I tried the following but it does not // work: var result = new IList&lt;Content.Grid&gt;(); var data = _contentRepository.GetPk(pk) .Select((t, index) =&gt; new Content.Grid() { PartitionKey = t.PartitionKey .... }); switch (pk.Substring(2, 2)) { case "00": return data .OrderBy(item =&gt; item.Order) .ToList(); break; default: return data .OrderBy(item =&gt; item.Order) .ToList(); break; } } </code></pre> <p>The VS2012 is telling me that the break is not needed so what I would like to do is to remove the returns from inside the switch, store the results in a variable and then after the switch is completed have:</p> <pre><code>return result; </code></pre> <p>Can someone tell me how I can declare the variable called result. I tried the following but this gives a syntax error:</p> <pre><code>var result = new IList&lt;Content.Grid&gt;(); </code></pre>
c#
[0]
4,074,927
4,074,928
Safe json parsing with jquery?
<p>I am using jquery with json. My client pages generate json, which I store on my server. The clients can then fetch the json back out later, parse, and show it.</p> <p>Since my clients are generating the json, it may not be safe. I think jquery uses eval() internally. Is that true? Is there a way to use the native json parsers from the browsers where available, otherwise fall back to manual parsing if not? I'm new to jquery so I don't know where I'd insert my own parsing code. I'm doing something like:</p> <pre><code>$.ajax({ url: 'myservlet', type: 'GET', dataType: 'json', timeout: 1000, error: function(){ alert('Error loading JSON'); }, success: function(json){ alert("It worked!: " + json.name + ", " + json.grade); } }); </code></pre> <p>so in the success() method, the json object is already parsed for me. Is there a way to catch it as a raw string first? Then I can decide whether to use the native parsers or manual parsing (hoping there's a jquery plugin for that..).</p> <p>The articles I'm reading are all from different years, so I don't know if jquery has already abandoned eval() already for json,</p> <p>Thank you</p>
jquery
[5]
5,696,915
5,696,916
Sorting list using reflection
<p>I have a table and i want to do sorting function for each column.</p> <p>Sorting has two direction asc and desc.</p> <p>1) How can i sort columns using reflection?</p> <pre><code>List&lt;Person&gt; GetSortedList(List&lt;Person&gt; persons, string direction, string column) { return persons.OrderBy(x =&gt; GetProperyByName(x, column)); //GetPropertyByName - ?? } </code></pre> <p>2) Also i want to do something what i can call chain of linq operators:</p> <pre><code> List&lt;Person&gt; GetSortedList(List&lt;Person&gt; persons, string direction, string column) { var linqChain; if(direction=="up") { linqChain+=persons.OrderBy(x =&gt; GetProperyByName(x, column)) } else { linqChain+=persons.OrderByDescending(x =&gt; GetProperyByName(x, column)) } linqChain+=.Where(....); return linqChain.Execute(); } </code></pre>
c#
[0]
4,642,227
4,642,228
.hide() is not working in Firefox but working in IE
<p>I want to display a layer and after clicking the close button I need to hide a layer. </p> <p>for this I am passing the value to the close function (user defined) in the jquery and used the below lines to close. Well it is working in IE but not working in Firefox.</p> <pre><code>$('.layer_close').click(function(){ $('#TB_overlay').hide(); </code></pre> <p>I tried to add the below code also but not helpful</p> <pre><code>&lt;script type="text/javascript"&gt; jQuery.noConflict(); jQuery(document).ready(function($){ //Do jQuery stuff using $ ... ... }); &lt;/script&gt; </code></pre>
jquery
[5]
1,140,781
1,140,782
Removing SurfaceView from the application stack
<p>Hello StackOverflow Users,</p> <p>I am new to android and trying to develop a game in which I use a </p> <p>1) Main class to redirect (like a menu.. new game, options, help, exit etc..)</p> <p>2) A surfaceview class</p> <p>3) A thread to handle drawing on canvas.</p> <p>I have added an exit button on the main class. </p> <p>However after playing the game i.e. drawing the objects and using them, when i redirect to my Main class and try to exit; the main screen disappears but the view and threads aren't destroyed.</p> <p>This is the main class.</p> <pre><code>package com.tgm.welcome; import com.tgm.R; import com.tgm.main.GThread; import com.tgm.main.TGMActivity; import com.tgm.options.OptionsMain; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.ImageView; import android.widget.Toast; public class Welcome_Act extends Activity { ImageView game, exit, options; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.welcome); game = (ImageView) findViewById(R.id.newGame); options = (ImageView) findViewById(R.id.options); exit = (ImageView) findViewById(R.id.exit); game.setOnClickListener(new View.OnClickListener() { public void onClick(View arg0) { gotogame(); } }); options.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goto_opt(); } }); exit.setOnClickListener(new View.OnClickListener() { public void onClick(View arg0) { exit_game(); } }); } public void gotogame() { Intent game = new Intent(Welcome_Act.this, TGMActivity.class); startActivity(game); } public void goto_opt() { Intent opt = new Intent(Welcome_Act.this, OptionsMain.class); startActivity(opt); } public void exit_game() { System.exit(0); } } </code></pre> <p>PLEASE HELP TO REMOVE THE GAMESCREEN FROM THE STACK THAT ANDROID MAINTAINS.</p> <p>Thanks..</p>
android
[4]
3,661,588
3,661,589
jQuery change image onclick
<p>Don't know why but I can't find a solution to this. I have 3 links that when clicked I want to change an image below using jQuery. Does anyone know of a really simple script to show me how this might work? Thanks in advance.</p>
jquery
[5]
6,014,295
6,014,296
Trying to create a 3 dimensional vector in c++
<p>So, im trying to create a 3 dimensional 5x3x2 vector, using the vector lib and saving the number 4 in every node.</p> <p>Thats what im trying:</p> <pre><code>vector&lt;vector&lt;vector&lt;int&gt; &gt; &gt; vec (5,vector &lt;int&gt;(3,vector &lt;int&gt;(2,4))); </code></pre> <p>for a bi dimensional 5x8 saving the int 6 in every node, this works:</p> <pre><code>vector&lt;vector&lt;int&gt; &gt; vec (5,vector &lt;int&gt;(8,6)); </code></pre>
c++
[6]
1,670,833
1,670,834
Internet Explorer 10 not redirecting
<p>With Internet Explorer 10 removing the browser detection through markup, I need a new way to redirect users using Internet Explorer to a new page</p> <p>I decided to use</p> <pre><code>&lt;body&gt; &lt;script type="text/javascript"&gt; if (navigator.appName == 'Microsoft Internet Explorer') { self.location = "http://&lt;url&gt;" } &lt;/script&gt; </code></pre> <p>, but nothing is happening. I am sure that there is something little missing that I am not seeing right now.</p>
javascript
[3]
3,054,771
3,054,772
Displaying a large panoramic image with offset in Android - Different technique?
<p>Are there different techniques to follow than the usual load image stuff for large panoramic images? </p> <p>For panorama section with an offset: Should I actually make a copy of the panorama, after cropping it to the screen size, before displaying it? </p>
android
[4]
1,222,578
1,222,579
How to invoke an action on keystroke or key binding
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/9075769/how-to-listen-to-keyboard-events-in-a-console-application">How to listen to keyboard events in a console application</a> </p> </blockquote> <p>Hi I am new to java syntax.I am trying to invoke an action on a keystroke like "ENTER key"</p> <p>For ex:</p> <pre><code>on pressing Enter key { int c = 9+8 ; //This should run on pressing enter key but not just running program directly printf("c"); } </code></pre> <p>I have referred few java doc relating to this and tried to execute the code.But I face few syntax errors. Can any one give direct example</p>
java
[1]
5,176,077
5,176,078
Create a Dynamic Hash JavaScript with unique Key
<p>I am trying to create some dynamic hashes in Javascript</p> <p>I have </p> <pre><code>Postcodes = ["one", "two"] </code></pre> <p>From this I am trying to create a hash with the key of the hash being the value from the array.</p> <pre><code>postcode_1 = Postcodes[0] postcode_2 = Postcodes[1] postcode1 = {} postcode2 = {} postcode1[postcode_1] = {foo: 1200, bar: "woo"}; postcode2[postcode_2] = {foo: 1200, bar: "woo"}; </code></pre> <p>This does not work what I need to end up with is a hash that looks like this</p> <pre><code>{"one": {foo: 1200, bar: "woo"} </code></pre>
javascript
[3]
5,508,845
5,508,846
Multiple setTimeout's
<p>There seems to be a conflict between my two timers, I want to know how to make them totally independent but executing on the same page.. Here is the code:</p> <p>WHEN THE PAGE LOADS</p> <pre><code>&lt;script language="javascript" type="text/javascript"&gt; window.onload = function() { setTimeout("AlterTwitterTimer();", 60000); setTimeout("MainStatusTimer();", 60000); } &lt;/script&gt; </code></pre> <p>OTHER RELATED SCRIPTS</p> <pre><code>function AlterTwitterTimer() { document.getElementById('TwitterTimer').innerHTML = '0'; } function MainStatusTimer() { document.getElementById('MainStatusTimer').innerHTML = '0'; } function DelayedRefresh(DashCity) { if(document.getElementById('TwitterTimer').innerHTML == '0') { document.getElementById('fmeProcess').src = '/ajax/twitter_feed_ajax.asp?id='NY'; document.getElementById('TwitterTimer').innerHTML = '1'; setTimeout("AlterTwitterTimer();", 60000); } } function DelayedStatusRefresh() { if(document.getElementById('MainStatusTimer').innerHTML == '0') { document.getElementById('fmeProcess').src = '/ajax/dash_board_status.asp'; document.getElementById('MainStatusTimer').innerHTML = '1'; setTimeout("MainStatusTimer();", 60000); } } </code></pre> <p>Any help you can provide would be great appreciated.</p> <p>Many thanks, Paul</p>
javascript
[3]
5,551,868
5,551,869
Why isn't "myObject ??= defaultValue;" possible in C#?
<p>Why isn't <code>myObject ??= defaultValue;</code> possible in C#?</p> <p>It would be very nice !</p>
c#
[0]
3,079,695
3,079,696
is it possible to get the total width of a jquery tab?
<p>is it possible to get the width of the different tabs with different lengths of text inside?</p> <p>for instance</p> <p>| tab 1 | motion sickness | computer |</p> <p>the tab 1 = 20px</p> <p>motion sickness tab = 100px</p> <p>computer tab = 60px</p> <p>something like that</p>
jquery
[5]