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 |
|---|---|---|---|---|---|
1,343,302 | 1,343,303 | How to sort with 2 or more sortexpression using comparer | <p>I must use a self-coded comparer to sort a list of objects.</p>
<pre><code>myObjectList.Sort(new MyComparer(_sortExpression, _sortDirection));
</code></pre>
<p>How can I append a 2nd expression and direction to sort by if values on 1st expression are equal?</p>
<p>I mean e.g.: Sort by last name and then if equal by first name. But I must use my own comparer.</p>
<pre><code>myObjectList.Sort(
new MyComparer(new string[]{_exp1, _exp2}, new string[]{_dir1, _dir2}));
</code></pre>
<p>Thanks in advance!
Lord Vader</p>
| c# | [0] |
2,969,094 | 2,969,095 | How do you host your own egg repository? | <p>Say you're on a team that's maintaining a lot of internal python libraries(eggs), and for whatever reason uploading them to pypi is not an option. How could you host the libraries(eggs) so that easy_install can still work for the members of your team?</p>
<p>Basically it would be cool if this worked....</p>
<pre><code>(someproj)uberdev@hackmo:~$ easy_install myproprietary.lib-dev
user: uberdev
password:...
fetching......
Searching for myproprietary.lib-dev
Reading http://dev.mycompany.corp/myproprietary.lib-dev
Reading http://dev.mycompany.corp
Reading http://dev.mycompany.corp/dist
Best match: myproprietary.lib-dev
Downloading http://dev.mycompany.corp/dist/myproprietary.lib-dev
</code></pre>
<p>I suppose there's some sort of servers out there that can be installed but I'd appreciate some guidance from the experts on this matter.</p>
<p>Thanks</p>
| python | [7] |
5,081,809 | 5,081,810 | deleting c-style array of int vectors | <p>I have declared:</p>
<pre><code>vector<int> * part = new vector<int>[indmap];
</code></pre>
<p>Ok, I know it: “why don’t you declare a vector of vector?”.
The next time I will do so, but now I would like to understand something more about vectors which I’m not able to solve.</p>
<p>Now I want to release all resources, what have I to do?</p>
<pre><code>delete[] part;
</code></pre>
<p>But before deleting the array what should I do to delete all the vector objects?</p>
| c++ | [6] |
857,529 | 857,530 | How to append new data to a list View inside a Fragment? | <p>So I've two fragments. One that posts data and one that shows the data in the activity. </p>
<p>So, once the post is done, I don't want to reload the entire Fragment, call the server, get all the data and show it. I just want to append the new piece of data to the fragment. How do I manage that? </p>
<p>Example: Twitter Direct Messages. When I send a direct Message, I don't have to load the entire list of Messages but just append the new message that I sent in the list View. How do I do that here?</p>
| android | [4] |
1,744,087 | 1,744,088 | Custom service in 'Accounts & Sync' | <p>I have a Twitter widget installed on my Android 2.1 and for now in
'Accounts & sync' app when I press 'Add account' I have ability to add
Twitter account. Moreover screens for adding Twitter account in 'Accounts
& sync' app are made in Twitter design.</p>
<p>Q: How I can put binding to my service in the 'Accounts & sync' as Twitter done?</p>
| android | [4] |
3,451,135 | 3,451,136 | Google API Translate not working for Language.HINDI | <p>I am attaching the code below. </p>
<pre><code>import com.google.api.translate.Language;
import com.google.api.translate.Translate;
public class Translator {
public static void main(String[] args) {
// Translate trans = new Translate();
try{
System.setProperty("http.proxyHost", "192.16.3.254");
System.setProperty("http.proxyPort", "8080");
Translate.setHttpReferrer("http://code.google.com/p/google-api-translate-java/");
String translatedText = Translate.execute("How are you?", Language.ENGLISH, Language.HINDI);
System.out.println("translated text :" + translatedText);
}catch (Exception e) {
e.printStackTrace();
}
}
}
</code></pre>
<p>This is giving output as
translated text : ?? ???? ????</p>
<p>but for Language.FRENCH,Language.SPANISH its giving the translated text.</p>
<p>Could you please tell a solution for this.</p>
| java | [1] |
5,890,440 | 5,890,441 | How to create a hyperlink from the data I get from a website with php | <p>I'm in the middle of a stuggle here, I successfully return data from a website, but then the hyperlink from the site returns as text instead of a link. I wonder if there is any way that I can return it as a link. Also is it possible to display the information inside the hyperlink?</p>
<pre><code><div data-role="content">
<div class="content-primary">
<?php
$query = 'http://query.yahooapis.com/v1/public/yql?q=Select%20*%20From%20rss%20where%20url%3D%22http%3A%2F%2Fworldoftanks.com%2Fnews%2Frss%2F%22&diagnostics=true';
$xml = simplexml_load_file($query);
//var_dump($xml);
echo '<h2>World of Tank News</h2>';
//iterate over query result set
$results = $xml->results;
foreach ($results->item as $r){
echo $r->title . "<br />";
echo $r->link . "<br /><br />";
}
?>
</div>
</code></pre>
| php | [2] |
608,447 | 608,448 | change font color of label at time interval in iphone sdk? | <p>i want to change the font color of the label at some time interval .can anyone tell how to do it ?</p>
| iphone | [8] |
5,490,676 | 5,490,677 | Python question relating to dated values in a csv file | <p>I am loading a data file with dated data into a csv.DictReader</p>
<p>The data looks like this:</p>
<pre><code>date, weight, blood_pressure, sugar_level
1/1/01, 120.1, 100.1, 25.2
2/1/01, 130.1, 102.1, 26.2
3/1/01, 110.1, 120.1, 24.2
4/1/01, 130.1, 130.1, 28.2
5/1/01, 160.1, 104.1, 27.0
6/1/01, 150.5, 100.1, 22.5
7/1/01, 120.2, 129.1, 25.2
... etc...
</code></pre>
<p>I want to write a function that allows me to pass in the dictionary (read from the csv file), and return the previous value of a column an epoch ago. Since there are no enumerations in Python, I will use enums to 'constrain' the permissible epochs and column names:</p>
<p>The code snippet I have so far looks something like this:</p>
<pre><code>import csv;
headers = ['date', 'weight', 'blood_pressure', 'sugar_level']
data = csv.DictReader(csvfile, headers);
epoch_type = (week_ago, fortnight_ago, month_ago);
column_names = headers[1:];
def function get_previous_value(data, column_name, epoch_name):
""" Note: data is assumed to be sorted in date ascending order """
""" Returns the previous value in the data, using the specified """
""" column name and epoch type """
</code></pre>
<p>I would be grateful if someone could show how to implement this function</p>
<p><strong>[Edit]</strong>
Changed argument name from 'lookback' to 'epoch_name' to aid clarity</p>
| python | [7] |
2,863,066 | 2,863,067 | jQuery attr title issue | <p>I'm not able to change the title attribute of div dynamically.
Here is my code : </p>
<p><strong>EDIT:</strong></p>
<pre><code><div id='DivId'></div>
</code></pre>
<p>this div is dialog div.
On click of button 'First' & 'Second', Dialog will open</p>
<pre><code>// On click of button First:
$('#DivId').removeAttr('title');
$('#DivId').attr('title','first');
// On click of button Second:
$('#DivId').removeAttr('title');
$('#DivId').attr('title','second');
</code></pre>
<p>On the first button click, <code>title</code> remains that only, however, on clicking of second button, the title does not change.</p>
<p><strong>EDIT</strong></p>
<p>if I remove <code>$('#DivId').removeAttr('title');</code> then also it is not working.</p>
| jquery | [5] |
2,420,793 | 2,420,794 | Representing a single byte | <p>A single <code>byte</code> takes up <strong>four bytes</strong> of space inside the Java virtual machine(<em>32 bit processor</em>).</p>
<p>Yes,we can use an array of byte which would occupy only the amount of space it actually needs. But I want to use a single byte <strong>not</strong> an array of bytes.</p>
<p>So,is there any <strong>type</strong> in <code>Java</code> to represent an <strong>8 bit datum</strong>.</p>
| java | [1] |
1,314,683 | 1,314,684 | getimagesize not working | <p>I'm trying to get the image size but not managing to do it. What could be the problem?</p>
<pre><code>$size = getimagesize("http://getfavicon.appspot.com/http://google.com?defaulticon=1pxgif");
echo $size[0];
</code></pre>
| php | [2] |
3,881,010 | 3,881,011 | C++ reading a sequence of integers | <p>gooday programers. I have to design a C++ program that reads a sequence of positive integer values that ends with zero and find the length of the longest increasing subsequence in the given sequence. For example, for the following
sequence of integer numbers:</p>
<pre><code>1 2 3 4 5 2 3 4 1 2 5 6 8 9 1 2 3 0
</code></pre>
<p>the program should return 6
i have written my code which seems correct but for some reason is always returning zero, could someone please help me with this problem. </p>
<p>Here is my code: </p>
<pre><code>#include <iostream>
using namespace std;
int main()
{
int x = 1; // note x is initialised as one so it can enter the while loop
int y = 0;
int n = 0;
while (x != 0) // users can enter a zero at end of input to say they have entered all their numbers
{
cout << "Enter sequence of numbers(0 to end): ";
cin >> x;
if (x == (y + 1)) // <<<<< i think for some reason this if statement if never happening
{
n = n + 1;
y = x;
}
else
{
n = 0;
}
}
cout << "longest sequence is: " << n << endl;
return 0;
}
</code></pre>
| c++ | [6] |
1,158,423 | 1,158,424 | Make initial capital in a user-supplied control name | <p>I have a function with the name MakeInitialCapital. I want to supply control name as an argument and the text in that control must be converted to Initial Capital.</p>
<p>How to modify this Javascript code:</p>
<pre><code>function MakeInitialCapitalControl(controlName)
{
TextInControl = getElementByID(controlName).value;
return str.toLowerCase().replace(/\b[a-z]/g, cnvrt);
function cnvrt() {
return arguments[0].toUpperCase();
}
</code></pre>
<p><strong>Edited:</strong></p>
<p>One more thing, if the text already has Intials Capital, make it lowercase.</p>
| javascript | [3] |
2,911,495 | 2,911,496 | How to draw SoftKeyboard keyCodes on a SurfaceView? | <p>I have a problem with the softkeyboard and the surfaceview. I want to write text on the surfaceview throught the onDraw method when I type in the soft keyboard. I get the event but I couldn't get the corresponding character to draw. I see a lot of post, and in someone it say that the getNumber() should respond with the corresponding character but it fail with badcodes.
Here is may onKey method:</p>
<pre><code>public boolean onKey(View v, int keyCode, KeyEvent event) {
Log.d(LOGTAG, "keyCode: "+keyCode+" - " + event.getNumber()+" Un: "+event.getUnicodeChar());
this.charToDraw = ""+event.getNumber();
this.forceOnDraw();
return false;
}
</code></pre>
<p>The DDMS show this:</p>
<pre><code>01-18 16:35:27.440: DEBUG/xxxxxxx(6227): keyCode: 47 - �� Un: 115
01-18 16:35:27.440: DEBUG/xxxxxxx(6227): onDraw: WRITING:��
</code></pre>
<p>I also try to use:</p>
<pre><code>char keyCode = (char)keyCode;
String keyCode = "" + keyCode;
</code></pre>
<p>but get the same result.</p>
<p>I need to transform the keyCode to a string to display with the drawString of the surfaceview canvas.</p>
| android | [4] |
1,537,886 | 1,537,887 | Why python does not allow hyphens | <p>I have always wondered why can't we use hyphens in between function names and variable names in python</p>
<p>Having tried functional programming languages like Lisp and Clojure, where hyphens are allowed. Why python doesn't do that.</p>
<pre><code># This won't work -- SyntaxError
def is-even(num):
return num % 2
# This will work
def is_even(num):
return num % 2
</code></pre>
<p>I am sure Sir Guido must have done this because of some reasons. I googled but couldn't manage to find the answer. Can anyone please throw some light on this?</p>
| python | [7] |
2,989,399 | 2,989,400 | Javascript function: nothing executes after a for(x in y) loop? | <p>I can't seem to find the answer to this anywhere...
I have a function that needs to set the bg color of two tables. Only the first table in the function is being affected. Is only one for loop allowed in a function? ...or is the 1st for loop maybe never exiting? </p>
<p>I can pretty much work around this by creating multiple functions but I really want to understand why this behaves the way it does!</p>
<p>Thanks!</p>
<p>Here is my simplified code:
</p>
<pre><code>function setColor()
{
//This works
var t1rows=document.getElementById("table1").getElementsByTagName("tr");
var x;
for (x in t1rows)
{
t1rows[x].style.backgroundColor='yellow';
}
//this one does not work
var t2rows=document.getElementById("table2").getElementsByTagName("tr");
var y;
for (y in t2rows)
{
t2rows[y].style.backgroundColor='yellow';
}
}
</code></pre>
| javascript | [3] |
3,376,896 | 3,376,897 | ILookup interface vs IDictionary | <p>How differs the ILookup interface from IDictionary ?</p>
<p>I don't understant what is the ILookup interface meant for.</p>
| c# | [0] |
2,742,833 | 2,742,834 | subtype reference argument compile error on gcc | <p>I have a problem compiling a c++ program with gcc version 4.6.3; I can compile this program with microsoft compiler (v 9.0) without problems.
This program is using some of my libraries I always used with microsoft compiler.</p>
<p>problem is when I try to pass a reference as argument that is a subtype of another: pseudo example here:</p>
<pre><code>class ObjManager{..}
class SubObjMng : public ObjManager{
public:
inline SubObjMng() : ObjManager(0, ... ){}
};
class Test{
public:
Test(int i, ObjManager &obj_mng);
}
int main(){
SubObjMng myobjmng;
Test t(0, myobjmng); //GCC ERROR HERE
}
</code></pre>
<p>output of the error is (real output for my program):</p>
<pre><code>globals.h:227:40: error: no matching function for call to cdk::HashMap::HashMap(unsigned int, cdk::PtrObjMng, cdk::cstrObjMng)
globals.h:227:40: note: candidates are:
contrib/cdklib/cdk_struct.h:485:12: note: cdk::HashMap::HashMap(uint32_t, cdk::ObjManager&, cdk::ObjManager&)
contrib/cdklib/cdk_struct.h:485:12: note: no known conversion for argument 2 from cdk::PtrObjMng to cdk::ObjManager&
</code></pre>
<p>anyone can help?
thanks!</p>
| c++ | [6] |
4,691,001 | 4,691,002 | Pass by Value and reference Java | <p>I am trying to write a copy method which can be used to copy a bean to bean by mapping the property names. if the source object is a cloneable object m cloning it and trying to return it to the calling method. but in calling method it change made in the called method is not reflecting </p>
<p>you might understand if u look at the below code</p>
<pre><code>public class Main {
public static void main(String[] args) {
HashMap<Object, Object> source = new HashMap<Object, Object>();
source.put("test1", "test1");
source.put("test2", "test2");
source.put("test3", "test3");
HashMap<Object, Object> destination = new HashMap<Object, Object>();
Main m = new Main();
Main.beanCopy(source, destination);
System.out.println("caller - " + destination);
}
public static void beanCopy(Object source, Object destination) {
if (source.getClass() == destination.getClass()
&& Cloneable.class.isInstance(source)) {
Class<? extends Object> cl = source.getClass();
try {
Method method = cl.getDeclaredMethod("clone");
destination = method.invoke(source);
System.out.println("callee - " + destination);
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
</code></pre>
<p>the output of this program is </p>
<pre><code>callee - {test1=test1, test2=test2, test3=test3}
caller - {}
</code></pre>
<p>I hope someone could help me to resolve this problem..
Thanks in advance...</p>
| java | [1] |
3,370,233 | 3,370,234 | jquery animate function and mimic the visuallightbox like effect | <p>EXAMPLE:
<a href="http://visuallightbox.com/lightbox-photo-software-sticky-notes-demo.html" rel="nofollow">http://visuallightbox.com/lightbox-photo-software-sticky-notes-demo.html</a> and click on any image to see how original image is showing.</p>
<p>I want to create the same effect with code instead of using a library.
The code that I'm using right now causes a similar effect, but it's not very smooth like visuallightbox.</p>
<p>Here is the code:</p>
<pre><code><ul>
<li>thumb</li>
<li>thumb</li>
<li>thumb</li>
<li>thumb</li>
<li>thumb</li>
<li>thumb</li>
<li>thumb</li>
<li>thumb</li>
<li>thumb</li>
</ul>
<div id="transition"><div>zoom effect<div></div>
$('ul li').click(function(e){
var $t = $('#transition'),
to = $(this).offset(),
td = $(document);
$t.children('div').css({width:100,height:100});
$t.css({
top: to.top + 50,
left: to.left + 50,
display: 'block'
}).animate({
top: td.height()/2,
left: td.width()/2
}, 600, function(){
$(this).animate({
top: '-=75',
left: '-=50'
}, 600);
$(this).children('div').animate({
width:250,
height:200
}, 600, function(){
// open dialog here
});
});
});
$('#transition').click(function(e){
$(this).hide();
});
</code></pre>
<p>How would I change this to get the desired effect?</p>
<p>fiddle: <a href="http://jsfiddle.net/HDmff/" rel="nofollow">http://jsfiddle.net/HDmff/</a> </p>
| jquery | [5] |
4,856,959 | 4,856,960 | Python: string.uppercase vs. string.ascii_uppercase | <p>This might be a stupid question but I don't understand what's the difference between string.uppercase and string.ascii_uppercase in the string module. Printing the docstring of both the function prints same thing. Even the output of <code>print string.uppercase</code> and <code>print string.ascii_uppercase</code> is same. </p>
<p>Thanks.</p>
| python | [7] |
2,072,093 | 2,072,094 | PHP check if file exists on my server, based on a full URL | <p>I have an app that generates invoices in the form of PDF files stored in a directory on my server. Before mailing out this invoices I'd like to make sure that the URL (not server path) which I store in my DB does indeed point to a valid PDF file. </p>
<p>Something could have gone wrong that wrote a value to that field in the db, but for example the filename is missing; meaning the file is not in the specified directory.</p>
<p>AFAIK file_exists just checks server paths but not URL's.</p>
<p>I could always store the server path too, or assemble it, but I'm wondering if i can do this check based on a full http url ending with a filename?</p>
<p>EDIT: yeah CURL occurred to me too but doesn't that seem a bit heavy for such a simple task? Perhaps I should just store the server path too.</p>
| php | [2] |
1,140,747 | 1,140,748 | check if a line exists in a file python | <p>How can I check if a line exists in a file and write the line to the file if it does not exist using Python</p>
<p>this is my current attempt</p>
<pre>
logfile = open('ip.log', 'a+')
while 1:
line = logfile.readline()
#line.replace("\n", "")
print line
if line == str(self.CLIENT_HOST):
print "Line Found Skipping"
else:
logfile.write(str(self.CLIENT_HOST)+"\n")
if not line:
print "EOF Reached"
break
print line
logfile.close()
</pre>
<p>cheers</p>
| python | [7] |
4,484,823 | 4,484,824 | Best language tooling | <p>I was listening to a podcast recently (may have been SO - can't remember) when the interviewee said that one of the reasons Java was so successful and popular was the tooling.</p>
<p>Having use of great FOSS editors such as Eclipse, NetBeans. Metrics tools such as Cobertura, Find Bugs, Build tools such as Maven and ANT.. I'd have to agree</p>
<p>I've done a fair bit of .NET and the tools are OKish. The problem seems to be that there isn't the depth in tooling that there is in Java. The FOSS stuff seems pretty limited. </p>
<p>My question: Are there any modern languages with a better community and tooling for getting the job done? </p>
| java | [1] |
5,663,811 | 5,663,812 | How come I can't lookup associated array like this? | <pre><code>urlMap = {
'0': {'6b4247404960fd4e418d242f3b7f0412': 'http://google.com', '123':'http://ibm.com'},
'1': {'4c27ffaef99b7a6dbe838b46bcc09779' : 'http://yahoo.com', '456':'http://abc.com'}
};
$(function() {
var l = new Array(1,2,3,4);
for (var i = 0; i < l.length; i++){
$("#"+i.toString()+".foo").change(function() {
g = i.toString();
window.location.href = urlMap[g][$(this).val()];
})}});
</code></pre>
<p>I tried to use urlMap[i] it won't work. When I hardcode urlMap['0'] it works.</p>
<p>From Firebug, I see this</p>
<pre><code>urlMap[g] is undefined
[Break On This Error]
window.location.href = urlMap[g][$(this).val()];
</code></pre>
<p>How am I suppose to lookup the dictionary?</p>
<p>Thanks.</p>
| javascript | [3] |
4,995,832 | 4,995,833 | How can I copy value from ostringstream to string? | <p>I tried :</p>
<pre><code>ostringstream oss;
read a string from file and put to oss;
string str;
str << oss.str();// error here "error: no match for ‘operator>>’ in 'oss >> str' "
</code></pre>
<p>If I use <code>str = oss.str();</code>
Instead of printing the value of the string, it prints out <code>"....0xbfad75c40xbfad75c40xbf...."</code> likes memory address.<br/>
Can anybody tell me why?
Thank you.</p>
| c++ | [6] |
2,841,753 | 2,841,754 | What is best and simple way to get view height except navigation bar? | <p>I want to get height of view except navigation bar. I used below method so far. Is there better way? And isn't it dangerous to hardcode height of navigation bar as 44.0? </p>
<pre><code>CGRect screenRect = [[UIScreen mainScreen] applicationFrame];
viewHeight = screenRect.size.height - 44.0;
</code></pre>
| iphone | [8] |
646,054 | 646,055 | How to call javascript function in code behind page | <p>any reference document </p>
| javascript | [3] |
5,554,060 | 5,554,061 | How do I index the 3 highest values in a list? | <p>so i have these 2 lists:</p>
<pre><code>score = [350, 914, 569, 223, 947, 284, 567, 333, 697, 245, 227, 785, 120, 794, 343, 773, 293, 995]
name = [Ryan, Stacy, Jenna, Peter, Sophie, Bryan, Cole, Andrea, Emily, Blake, Mike, Stephan, Rob, Eliza, Heather, Daniel, Elisabeth, Samantha]
</code></pre>
<p>I have to find the 3 highest scores and tally these scores with their respective scorers in the name list, so that I can have new lists</p>
<pre><code>top3score = [947, 995, 914]
top3name = [Sophie, Samantha, Stacy]
</code></pre>
<p>I'm thinking of indexing the highest scores, appending them into a list than using the index to tally these scores with the names.</p>
<p>my question is how do i index the 3 highest values in the list?
and then, how do i use the index to look for the scorers name in the name list so that i can append them in the top3name list?</p>
| python | [7] |
1,015,111 | 1,015,112 | Sending in-app email | <p>I need to send an email without exiting the application as the subject and body are already set by the application. I already know how to send an email but I need to exit the application to the email application and click on send to go back to my application. Can't I just send the email without exiting or at least without needing to click on send button, can't there be some sort of a framework that auto-sends the email?</p>
<p>Kind Regards,
Heba</p>
| iphone | [8] |
3,744,144 | 3,744,145 | java process slow on windows local system account | <p>A third party web app I am using will generate a hookable event under certain situations. The hook can launch any Windows process, and I wrote a Web Service app (in Java) that does some things based on the event that was fired. I wrapped the Java app in a Batch file to set the path and some other things since it is exec'ing in the background.</p>
<p>The Windows BAT file works just fine if I run it from a Windows command prompt. The Web Services get called and everything is cool. But when it is exec'ed from the hook, it is as if it is given the lowest possible priority for a process - I can see in Task Manager it is running, but it never can complete the HTTPS handshake to the Web Service I am calling. I know this because I put in a lot of logging to see what is going on when it is exec'ed. No exceptions are thrown, and from the log messages, it is spending all its time trying to establish the HTTPS connection. And yes, I turned off the Windows firewall. I wrote my own Trust Manager, so it not trying to do cert validation.</p>
<p>It is running on the SYSTEM account, which makes me think the problem has something to do with that since it works fine from my own account. It is not accessing any Windows network resources.</p>
<p>The Web Service code I am using is Apache Axis 1.6.</p>
<p>I do not have access to the third party app's code. </p>
<p>Any ideas? </p>
<p>Thanks</p>
| java | [1] |
3,688,044 | 3,688,045 | Java Property Change listeners | <p>I would like to know , how the java beans property change listeners work.
Do they use , EventListeners inside ?
Is it good to use , property change listeners when we can do same with POJO implementation
of mediator pattern . I mean performance wise ?</p>
<p>Thanks
J</p>
| java | [1] |
1,365,420 | 1,365,421 | non standard package name - will it cause trouble? | <p>I have rather stupidly published a game on the android market with a package name of mick.game.tangletwister, whereas I should have called it com.rai.tangletwister (where rai is the name of my company)... it all seems to work fine - but could it cause some trouble in the future - should I change it? And if I do change it, will it cause problems for existing users that grab the updated version?</p>
| android | [4] |
253,267 | 253,268 | Can We use one UIViewController class for tab-bar's | <p>Can We use one UIViewController class for tab-bar application. Which has two tabs'' need to bind data in UIViewController with out effecting data in UIViewController when tab is changed. </p>
| iphone | [8] |
883,094 | 883,095 | Runtime.availableProcessors: what is it going to return? | <p>The javadoc for <code>Runtime.availableProcessors()</code> in Java 1.6 is delightfully unspecific. Is it looking just at the hardware configuration, or also at the load? Is it smart enough to avoid being fooled by hyperthreading? Does it respect a limited set of processors via the linux <code>taskset</code> command?</p>
<p>I can add one datapoint of my own: on a computer here with 12 cores and hyperthreading, Runtime.availableProcessors() indeed returns 24, which is not a good number to use in deciding how many threads to try to run. The machine was clearly not dead-idle, so it also can't have been looking at load in any effective way.</p>
| java | [1] |
3,020,120 | 3,020,121 | Android: Is it possible to add functionality to the call screen? | <p>Is it possible to customize the call screen in Android? Example would be, two users have the same application, user calls, but the other user cannot pick up, so they respond with some type of predetermined image baked into the application.</p>
<p>Is this possible?
Does this break any rules?</p>
| android | [4] |
1,628,333 | 1,628,334 | activity redirection problem in android | <p>hi all
i have an app with 3 activity. if i launch the app the first time it have to redirect to second activity from first activity. after the first time launch the app it have to go to third activity from first activity. how to do that? please help me. is there way to without using database?</p>
| android | [4] |
792,459 | 792,460 | Are php statements executed syncronously? | <p>Ok this seems like a stupid question that I should certainly know the answer to, but I've got some weird behavior where the constructor of one of my classes checks to see if a table exists, if not it creates it.</p>
<p>The strange thing is when the table doesn't exist, if the constructor is called multiple times then it doesn't see the table that should have been created on the first constructor call.</p>
<p><strong>Are all function calls synchronous in PHP?</strong> </p>
<p>For example:-</p>
<pre><code>f1();
f2();
</code></pre>
<p>Does the interpreter wait for <code>f1()</code> to return before calling <code>f2()</code>?</p>
| php | [2] |
5,645,446 | 5,645,447 | How to iterate between 0.1f and 1.0f with 0.1f increments in Java? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/5257166/java-floats-and-doubles-how-to-avoid-that-0-0-0-1-0-1-0-9000001">Java floats and doubles, how to avoid that 0.0 + 0.1 + … + 0.1 == 0.9000001?</a> </p>
</blockquote>
<p>I am having a following problem in Java - I need to iterate between 0.1f and 1.0f in 0.1f increments,so I would like my output to look like this:</p>
<pre><code> 0.1
0.2
0.3
0.4
...
0.9
</code></pre>
<p>Instead,when I do:</p>
<pre><code>for(float i = 0.1f; i < 1f; i += 0.1f)
System.out.println(i);
</code></pre>
<p>I get</p>
<pre><code>0.1
0.2
0.3
0.4
0.5
0.6
0.70000005
0.8000001
0.9000001
</code></pre>
<p>I imagine it has something to do with the way fractions are represented by a computer,but I would like to know why is this,and if there is anything I can do to stop it.
thanks.</p>
| java | [1] |
5,591,516 | 5,591,517 | Beginning PHP for someone interested in Security | <p>I'd like to learn PHP specifically for dealing with security vulnerabilities/exploits.</p>
<p>Could someone recommend a book?</p>
<p>I don't know if I need to learn HTML/CSS/XML/XHTML etc, do I have to learn those too? I don't really plan on designing websites, could anyone help me with this? :P</p>
| php | [2] |
3,077,970 | 3,077,971 | regular expression in javascript? | <p>I am new to javascript and recently I wanted to use regular expression in order to get a number from url and store it into a var as string and another var as digit. For example I want to get the number 55 from the bellow webpage (which is not an accrual page) and I want to store it in a var.
I tried this but it is not working</p>
<pre><code>https://www.google.com/55.html
url.replace(/(\d+)(\.html)$/, function(str, p1, p2) {
return((Number(p1) + 1) + p2);
</code></pre>
<p>Please I need help but not with Jqurey because it does not make a lot of sense to me.</p>
| javascript | [3] |
3,854,333 | 3,854,334 | Pass Data From Activity To Dialog | <p>I am looking for a way to pass data from an activity onto a dialog box. I am trying to call <code>showDialog(int);</code>, however i don't see a way to pass any data to the dialog box.
I need to pass a string to the dialog box in order to display a confirmation :)</p>
<p>Cheers</p>
| android | [4] |
4,178,119 | 4,178,120 | how to add a button in android? | <p>I am new to android.</p>
<p>Tell me how to add a button in android. And when we clicks on it it has to do a activity</p>
| android | [4] |
5,794,185 | 5,794,186 | Include using local path | <p>I need to include a file in a page,
usually I do this:</p>
<pre><code><?php
include("/homes3/sub94/sc9493/www/app/webroot/img/include1.php");
?>
</code></pre>
<p>But I would like to use the Path from the bootstrap,
to have more clear code, for example something like this:</p>
<pre><code><?php
include(SRC_LOCAL_PATH.'/adv-japan.php');
?>
</code></pre>
<p><strong>Why it doesn't work?</strong></p>
<p>I know I can do something like
$path= SRC_LOCAL_PATH.....
but I would like to know if I can just write one line of code, without the variable to get the path, so I would like to have something like: </p>
<p>..
Please note that with this:</p>
<pre><code><?php
echo SCR_LOCAL_PATH;
?>
</code></pre>
<p>the result is the correct path taken from bootstrap:
<code>/homes3/sub94/sc9493/www/app/webroot/img/</code></p>
| php | [2] |
5,925,733 | 5,925,734 | Php check duplicate values in an array | <p>I have a question about arrays.</p>
<p>I have made an array of id's.</p>
<p>The array looks a little like this.</p>
<pre><code>$iIds[0] = 12
$iIds[1] = 24
$iIds[2] = 25
$iIds[3] = 25
$iIds[4] = 25
$iIds[5] = 30
</code></pre>
<p>Now i need code to see if any of the values are in the array multiple times.
Then, if the value is in the array 3 times, inject the value into another array.</p>
<p>I tried using array_count_values() , but it returns with the values as keys.</p>
<p>Can anyone help me with this?</p>
| php | [2] |
5,387,262 | 5,387,263 | Alert Dialog outside of an App (not in an Activity) | <p>Is there a way to create some sort of popup window like an Alert Dialog, outside of an App? The context of this question is I have a need to display something to the user in the event of a Push Notification. Basically, a user receives some message, the App receives it even if it's not currently open, and a notification appears in the user's task bar. If the user opens the notification in their task bar, I want a popup to appear completely independent from the App.</p>
<p>The only solution I've found so far is calling an Activity with the Theme.Dialog setting create an Alert Dialog. The problem with this solution is that the Activity will be added to the Activity Stack if the App is already open. So I get inconsistent behavior, because if the App is closed, then the popup window will work as I want, and will display in whatever app the user is currently in. However, if the App is already open, but not currently in focus, then the focus will switch to my App, and then display the dialog.</p>
<p>Ideally, I would want the popup to display independently of the app, with a button to redirect the user to the app if they choose, or to simply close the notification and continue whatever they're doing.</p>
<p>Anyone have any ideas?</p>
| android | [4] |
6,022,999 | 6,023,000 | XML Processor supporting schema 1.1 | <p>I want to to write a schema in xsd 1.1. Can somebody let me know if there is any Java xml processor supporting schema 1.1?</p>
| java | [1] |
5,751,400 | 5,751,401 | printing a UL from an array of images | <p>I am trying to print a UL list of images ending with _th.jpg returned from a specific folder. All i get back is array()</p>
<pre><code><?php
require '../../config.php';
$conn = new PDO(DB_DSN, DB_USER, DB_PASS);
$id = (int)$_GET['id'];
$q = $conn->query("SELECT * FROM cms_page WHERE id=$id");
$project = $q->fetch(PDO::FETCH_ASSOC);
$q->closeCursor();
$imagesDir = 'public/images/portfolio/'.$project['slug'].'/';
$images = glob($imagesDir . '*_th.{jpg,jpeg,png,gif}', GLOB_BRACE);
echo $imagesDir ;
print_r($images);
?>
<h1><?=htmlspecialchars($project['title'])?></h1>
<?php
if ($images < 1) {
echo '<div id="slider">';
echo '<ul>';
foreach($images as $key => $value) {
echo '<li><a href="public/images/portfolio/i-vis/1.jpg" rel="shadowbox[iVis]" title="Fully Content Managed Website"><img src="public/images/portfolio/'.$project['title'].'/'.$value.'.jpg" width="160" height="96" /></a></li>';
}
echo '</ul>';
echo '</div>';
} else {
echo 'There are currently no images to display for tihis project.';
}
?>
</code></pre>
<p>Anyone got any ideas?</p>
| php | [2] |
376,844 | 376,845 | Style element with javascript | <p>I am trying to make a gototop button with javascript (not jQuery).
I want this button to have a delay effect which I achieve by:</p>
<pre><code> var timeOut;
function scrollToTop() {
if (document.body.scrollTop!=0 || document.documentElement.scrollTop!=0){
window.scrollBy(0,-50);
timeOut=setTimeout('scrollToTop()',10);
}
else clearTimeout(timeOut);
}
</code></pre>
<p>The html is a simple:
<code><div id="gototop"><a href="#header" onclick="scrollToTop();return false">Back to top</a></div></code></p>
<p>I am not able to make to button show/hide depending on scroll height. As far as I have been able to find out, the following should hide the button from view until the page has been scrolled down 600px, but this does not work:</p>
<pre><code> var posit = window.scrollTop();
if (posit < 900) {
document.getElementById("gototop").style.display = 'none';
}
</code></pre>
<p>Why does this styling not take effect?</p>
<p>The complete code I am using is:</p>
<pre><code> var posit = window.scrollTop();
if (posit < 900) {
document.getElementById("gototop").style.display = 'none';
}
var timeOut;
function scrollToTop() {
if (document.body.scrollTop!=0 || document.documentElement.scrollTop!=0){
window.scrollBy(0,-50);
timeOut=setTimeout('scrollToTop()',10);
}
else clearTimeout(timeOut);
}
</code></pre>
<p>Thanks for your attention, greetings.</p>
| javascript | [3] |
5,819,600 | 5,819,601 | How do you split a string array | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/1100371/grabbing-a-segment-of-an-array-in-java">Grabbing a segment of an array in Java</a> </p>
</blockquote>
<p>I have a String[] which might contain 3, 6, 14 or 20 elements. I want to process 10 elements from the String[] array each time. </p>
<p>(e.g. for 3 or 6 it will loop once and twice for 14 or 20)</p>
| java | [1] |
532,947 | 532,948 | How to know user's language? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/1043339/javascript-for-detecting-browser-language-preference">JavaScript for detecting browser language preference</a><br>
<a href="http://stackoverflow.com/questions/3770513/detect-browser-language-in-php">Detect Browser Language in PHP</a><br>
<a href="http://stackoverflow.com/questions/8582405/whats-best-method-to-detect-language">What's best method to detect language?</a> </p>
</blockquote>
<p>I have created a website that anyone in the world can visit.</p>
<p>So, I need a way to know approximately what is the user's language without asking them.</p>
<p>Obviously, there is also a link that sets the language via cookie.</p>
| php | [2] |
2,680,216 | 2,680,217 | Assign values to Int Array (without repeating!) | <p>I need to assign values to an IntArray with 1000 elements randomly. But the elements cannot be repeated. I used this code...</p>
<pre><code>public int[] Numbers()
{
Random random = new Random();
int check;
for (int i = 0; i < numbers.Length; i++)
{
check = random.Next(0, 9999);
while (!numbers.Contains(check))
{
numbers[i] = check;
}
}
return numbers;
}
</code></pre>
<p>But then, an amount of numbers get the default values (0). What am I doing wrong ?</p>
| c# | [0] |
3,490,080 | 3,490,081 | How to make a windows form app with a language? | <p>I mean that Visual C# can make a windows form app easily, but i want to know how C# can make WFA (because Visual C# just is a ide). how a Windows Application(not Console) can run in windows.</p>
| c# | [0] |
3,794,569 | 3,794,570 | jquery toggle slideUp/slideDown | <p>I've got a div#items and if it's clicked then div#choices slideDown(). If it's clicked again then div#choices should slideUp(); How can I test if choices is down or up already? I know I could store in a variable and toggle it's value whenever div#items is clicked, but what if #choices has been slid down by other means?</p>
| jquery | [5] |
4,933,271 | 4,933,272 | What does .asmmeta file stand for | <p>I am not sure if this is a correct forum to ask this but I couldnt find a suitable answer googling for it .SO here i go,
Just want to know what does .asmmeta file contain in for a csproject file and what is the impact if we dont have one created for our project file?</p>
| c# | [0] |
105,757 | 105,758 | Exception in thread | <pre><code> public class Intro extends JFrame implements ActionListener {
ImageIcon pic = new ImageIcon(this.getClass().getResource("cars-games.jpg"));
JLabel l1 = new JLabel();
Image car = pic.getImage();
public static void main (String[]args){
Intro i = new Intro();
i.show();
}
}
</code></pre>
<p>Its giving me this error:</p>
<pre><code>Exception in thread "main" java.lang.NullPointerException
at javax.swing.ImageIcon.<init>(Unknown Source)
at Intro.<init>(Intro.java:15)
at Intro.main(Intro.java:58)
</code></pre>
<p>Can anyone help plz.</p>
| java | [1] |
29,358 | 29,359 | Replacing a character in a string costs? | <p>Is string class of stl mutable ? What does it cost to replace a character in a string with an integer cast to character ? </p>
| c++ | [6] |
5,295,381 | 5,295,382 | jQuery closest() not grabbing element | <p>Ok the .closest() function is not grabbing the element correctly or AT ALL so the class is not being added to the div. What's wrong here?</p>
<p>HTML:</p>
<pre><code><div class="half control-group">
<div class="form-status"></div>
<?php
echo form_label('Username', 'username');
echo form_input(array('name' => 'username', 'maxlength' => 25, 'value' => set_value('username') ));
?>
</div>
</code></pre>
<p>JQuery:</p>
<pre><code>success: function(label) {
$(label).text('');
$(label).closest('div[class="form-status"]').addClass('success');
//label.text('OK!').addClass('valid').closest('.control-group').addClass('success');
}
</code></pre>
<p>It's making the text go to blank correctly, but it's not changing the closest form-status div class... i even tried closest('.form-status') and it still won't grab it.
I'm using the validate jQuery plugin.
When you start typing it adds this HTML underneath the input bars:</p>
<pre><code><label for="name" generated="true" class="error valid" style></label>
</code></pre>
<p>FOR ANYONE LOOKING FOR THE CORRECT ANSWER, THIS WORKED:</p>
<pre><code>label.closest('.control-group').find('div.form-status').addClass('success');
</code></pre>
| jquery | [5] |
5,920,776 | 5,920,777 | get directory list from external file server using asp.net | <p>Can someone please help me in getting the list of directories from an external file server using ASP.net</p>
<p>Any help is appreciated!!</p>
| asp.net | [9] |
4,416,972 | 4,416,973 | jQuery Selector - Tabindex = -1 | <p>Is it possible to write a jquery selector for an element based on its tabindex?</p>
<p>E.g.</p>
<pre><code><div TabIndex='-1'>jQuery me up baby</div>
</code></pre>
| jquery | [5] |
5,438,051 | 5,438,052 | unable to fetch the id of dynamically generated button in jquery | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/9484295/jquery-click-not-working-for-dynamically-created-items">jQuery click not working for dynamically created items</a> </p>
</blockquote>
<pre><code> $(document).ready(function(){
$('#btn').click(function(){
var createInput=$("<input type='button'>");
createInput.attr("id","close1");
createInput.attr("value","close");
$('#outer-div').append(createInput);
});
$("#close1").click(function(){
alert('hi');
});
});
</script>
</head>
<body>
<div id='outer-div'>
<input id='btn' type='button' value='click here'/>
</div>
</code></pre>
<p><strong>What's wrong with the code. I am not getting the alert when i click the dynamically generated button named as close. Please help it out</strong></p>
| jquery | [5] |
2,277,646 | 2,277,647 | Why does new String("") compile while char c = '' does not? | <p>Why are empty Strings valid and empty chars are not ?
I would have thought an empty String is not a string but just a placeholder. The same for a char, but creating an empty char does not even compile. </p>
<p>What im wondering is why the following occurs -
Compiles - </p>
<pre><code>String s = "";
</code></pre>
<p>Does not compile -</p>
<pre><code>char c = '';
</code></pre>
| java | [1] |
1,144,327 | 1,144,328 | How to highlight words in html using jquery | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/119441/highlight-a-word-with-jquery">Highlight a word with jQuery</a> </p>
</blockquote>
<p>I want to highlight certain words in html <code><body></code> tag, but I want to avoid highlighting those which are within <code><a></code> tag. How can this be done? By highlight I mean, underlining and making word bold.</p>
<p>For e.g I have this html content </p>
<pre><code><body>
<p>
This is sample text for the purpose of highlighting searched text. Please visit <a href="javascript:void(0)">www.sampleSite.com</a>
</p>
</body>
</code></pre>
<p>Now when I search for the word "sample", I would not want to highlight the word <strong>sample</strong> contained within that anchor tag.</p>
| jquery | [5] |
1,913,399 | 1,913,400 | clear back stack in android | <p>Is that possible to clear back stack in android if all activity launch mode is single top.I already used clear Top flag but that is not working for this situation please let me suggest how to clear it </p>
| android | [4] |
1,080,636 | 1,080,637 | News headline keyword notification? | <p>I would like to make an app that notifies you when a news story is posted with certain keywords in its title, maybe have various news sites to "scan". Fairly new to programming and would like any advice or assistance, Thanks </p>
| android | [4] |
3,531,251 | 3,531,252 | flash app calling javascript functions stops suspends processing when Javascript alert() is called | <p>I have a flash application that is making javascript calls at various intervals.</p>
<p>for QA we want to display what args the flash app called the javascript.</p>
<p>The original developer used alert. however that stops the app from functioning until the ok button is clicked.( not what we wanted). Trying the other dialogs. those also stopped the app.</p>
<p><strong>I need a browser independent way (IE6+, safari, some really old version of firefox+, opera) to display what the flash app sends to javascript and not have it stop my flash app.</strong></p>
<p>I thought about console.log(), but IE6 does not support that.</p>
<p><strong>I am hoping someone can give me an alternative to writing a div in the page and having the javascript dump the message in the div.</strong></p>
| javascript | [3] |
1,488,514 | 1,488,515 | How do I properly dereference a buffer? | <p>I am having some memory problems with a project of mine. After a bit of tracing memory on several positions in my program, I retraced the problem to this line:</p>
<pre><code>(FloatBuffer)lightBuffer.asFloatBuffer().put(lightAmbient).flip()
</code></pre>
<p>I am using the resultant buffer in a function straight away, but it seems that that float buffer is not emptied after it has been used.
So how do I properly empty/dereference a buffer in java? </p>
<p>ps: I tried the clear() method, but according to the java documentation that only resets the buffer; it does not remove the data from it.</p>
| java | [1] |
5,472,432 | 5,472,433 | How to convert a vector<string> to null terminated char **? | <p>I'm trying to convert a <code>std::vector<std::string></code> to a NULL terminated array of C-style strings (<code>char *</code>). Is it possible without copying with <code>new</code>/<code>malloc</code>?</p>
<p>Basically, I want to convert vec back into the EXACT SAME thing as arr without new/malloc.</p>
<pre class="lang-c prettyprint-override"><code>#include <string>
#include <vector>
#include <stdio.h>
using namespace std;
void print(const char **strs)
{
const char **ptr = strs;
while(*ptr) {
printf("%s ", *ptr);
++ptr;
}
}
void print(std::vector<std::string> &strs) {
for(auto iter = strs.begin(); iter != strs.end(); ++iter) {
printf("%s ", iter->c_str());
}
}
void main()
{
const char *arr[] = { "a", "b", "c", "d", "e", "f", NULL };
vector<string> vec;
const char **str = arr;
while(*str) {
vec.push_back(*str);
++str;
}
vec.push_back((char *) NULL); //Doesn't work
//print(vec);
print((const char **) &vec[0]);
}
</code></pre>
| c++ | [6] |
4,451,630 | 4,451,631 | Removing specific QueryStrings | <p>Let's assume an aspx page gets multiple querystrings, for example <code>books.aspx?author=Arthor&level=4&year=2004</code>.</p>
<p>I'd like to create a button that clears specific querystring.</p>
<p>For example when <code>clearAuthorBtn</code> is clicked, user should be redirected to <code>books.aspx?level=4&year=2004</code></p>
<p>How can I make it?
Thank you very much.</p>
| c# | [0] |
441,207 | 441,208 | Javascript to return IP | <p>I have a hotfolder on a server. I want a Java script that will recognize the computer (ip) the file came from when it was dropped on the hot folder so that I can then assign an email to the ip and send automated emails to the owner of the hot folder task.</p>
<p>Thanks for reading.</p>
| javascript | [3] |
5,577,147 | 5,577,148 | Populating ComboBox | <p>i have this questions... my scenario is to populate combobox from the database and display customer name and hold a value of the id...my id i use identity increment...tnx</p>
<pre><code>SqlConnection conn = new SqlConnection(connectionString);
conn.Open();
//SelectCustomerById(int x);
comboBoxEx1.Items.Clear();
SqlCommand comm = new SqlCommand("spSelectCustomerByID", conn);
//comm.Parameters.Add(new SqlParameter("cust_name", cust_name));
//comm.CommandText = "spSelectCustomerByID";
comm.Parameters.Add(new SqlParameter("cust_id", SqlDbType.Int));
comm.CommandType = CommandType.StoredProcedure;
comm.ExecuteNonQuery();
SqlDataAdapter sdap = new SqlDataAdapter(comm);
DataSet dset = new DataSet();
sdap.Fill(dset, "cust_registrations");
if (dset.Tables["cust_registrations"].Rows.Count > 0)
{
comboBoxEx1.Items.Add("cust_registrations").ToString();
}
comboBoxEx1.DataSource = dset;
comboBoxEx1.DisplayMember = "cust_name";
</code></pre>
| c# | [0] |
5,944,426 | 5,944,427 | Handle "File save as" event in JS | <p>I need:
1) Get data from server by button click. (can ajax)
2) Execute some js depending on the received data.
3) Show standard "File save as" dialog.<br>
It must work in IE7/IE8/FF.</p>
<p>Thanks! And sorry for my crooked english =)</p>
| javascript | [3] |
4,694,455 | 4,694,456 | creating menu in Android | <p>I am creating android application which involves menu.Can anyone provide me the sample code code of creating menu.
Thanks in advance</p>
<p>Tushar</p>
| android | [4] |
2,491,714 | 2,491,715 | Java remove duplicates from linked list | <p>I want to remove duplicates from sorted linked list {0 1 2 2 3 3 4 5}. </p>
<p>`</p>
<pre><code>public Node removeDuplicates(Node header)
{
Node tempHeader = null;
if(header != null)
tempHeader = header.next;
else return header;
Node prev = header;
if((tempHeader == null)) return header ;
while(tempHeader != null)
{
if(tempHeader.data != prev.data)
{
prev.setNext(tempHeader);
}
tempHeader = tempHeader.next;
}
prev = header;
printList(prev);
return tempHeader;
}
</code></pre>
<p>`</p>
<p>prev.setNext(tempHeader) is not working correctly inside the while loop. Ideally when prev = 2 and tempHeader = 3, prev.next should be node with data = 3.</p>
<p>Printlist function just takes header pointer and prints the list.</p>
<p>Node definition is given below.</p>
<pre><code>public class Node
{
int data;
Node next;
public Node getNext() {
return next;
}
public void setNext(Node next) {
this.next = next;
}
}
</code></pre>
| java | [1] |
301,348 | 301,349 | Error or not and insert to database mysql | <p>Why wont this work? </p>
<pre><code><?php include "top.php";
include "connect.php";
if(isset($_POST["submit"])) {
$error = "";
if(empty($_POST["name"])) {
$error .= "Du glömde märket!<br>";
if(empty($_POST["rating"])){
$error .= "Du glömde att bedömma märket!<br>";
if(empty($_POST["worth"])){
$error .= "Du glömde att välja vilken klass den hör till!<br>";
if(empty($_POST["username"])){
$error .= "Du glömde att skriva ditt namn!<br>";
if(empty($_POST["rating"])){
$error .= "Du glömde att skriva någonting?!!<br>";
}}}}}
if(!empty($error)){
echo $error;
}else{
$name = $_POST["name"];
$rating = $_POST["rating"];
$worth = $_POST["worth"];
$favorite = $_POST["favorite"];
$username = $_POST["username"];
$description = $_POST["description"];
mysql_query("INSERT INTO brands (name, rating, worth, favorite, username, description) VALUES ('$name', '$rating', '$worth', '$favorite', '$username', '$description')");
echo "<span style='color: green'>Yir yir, <a href='brand.php'>klicka här för att gå till Märken.</a></span>";
}
}
</code></pre>
<p>It doesnt come with errors it just say the succeed message like it has inserted to database</p>
| php | [2] |
2,742,218 | 2,742,219 | Can't get .next() to work | <p>I'm trying to add a class so that the span text shows on hover,
but only for that particular image not all images at once.</p>
<p>I can get it to add class to all the spans at once, but when I try to limit it to only the span being hovered nothing happens. The problem seems to be when I add .next('span') - although I don't know why.</p>
<p>Can anyone tell me what I'm doing wrong here?</p>
<pre><code> $('.scroller-image').hover(function() {
$(this).next('span').addClass('hover');
}, function() {
$(this).next('span').removeClass('hover');
});
</code></pre>
<p>Here's the markup:</p>
<pre><code><div class="scroller-image">
<span>image title</span>
<img src="#" alt="#" />
</div>
</code></pre>
| jquery | [5] |
4,945,676 | 4,945,677 | pic all contact from phonebook and show with chechbox in android | <p>i want to pick all contact from Android phonebook and want to store them in a list with using cursor and listview. so that i can put checkbox in the list to select multiple contact from the phonebook.</p>
<p>how can i achieve this ?</p>
<p>thanks in advance</p>
| android | [4] |
2,036,133 | 2,036,134 | Available languages for speech recognition | <p>From what I've read, speech recognition is available for 3 languages: English (UK, US, Au ..), Japanese and Chinese (Mandarin).</p>
<p>Does anyone know more details about how to switch between these languages?
Is there a way to know (programatically) which language is active for speech recognition on a certain device? (maybe in Japan the only have Japanese ... but can I get this information somehow ... like a property or anything?).</p>
<p>Any help regarding this will be appreciated. </p>
<p>Thanks guys.</p>
| android | [4] |
4,766,324 | 4,766,325 | Android licensing server real use scenario? | <p>It seems like the example they give for the licensing server uses the main activities window to display licensing. I'm wondering what is a realworld example that uses the licensing server. </p>
<p>Use their main sample activity and if it allows go right to your actual main activity? </p>
<p>It seems like there should be a sample that checks access with NO UI but pops up a UI only in the case of a licensing problem. That sounds more realworld to me.</p>
<p>Is there some example code that shows an example like that somewhere?</p>
<p>Thanks</p>
| android | [4] |
4,164,232 | 4,164,233 | Javascript: How to Keep Persistant Array Data | <p>I'm trying to build an array in javascript that contains a list of ids. Here is a simplified version of the function that I have...</p>
<pre><code>function updateCost(id) {
var inputArray = [];
inputArray.push(id);
}
</code></pre>
<p>And here is the html code...</p>
<pre><code><input type="file" name="field1" id="field1" onchange="updateCost('1');" />
<input type="file" name="field2" id="field2" onchange="updateCost('2');" />
<input type="file" name="field3" id="field3" onchange="updateCost('3');" />
...
</code></pre>
<p>What I would like to happen, is each time I select a file from my computer using one of the file input fields that I have, I would like the id of that input field to be stored in the inputArray array. However, every time I select a file, it adds that id to the array, but it doesn't append it to the array, so everything else in the array is deleted, leaving only one entry in the array.</p>
<p>Is there any way to make the array data persistent so it will grow each time I use one of the of the file input fields?</p>
<p>Thanks!</p>
| javascript | [3] |
3,258,920 | 3,258,921 | substituting image source on click | <p>Firts noob here,</p>
<p>I have this script...</p>
<pre><code>$.backstretch( img, options, callback );
</code></pre>
<p>I need to code this such that the image source is a variable that gets replaced when a thumbnail is clicked on, with the image link associated with that thumbnail.</p>
<p>Also the previous image needs to be removed because this script bunches the images together if the previous image is not removed.</p>
<p>Any help would be much appreciated.</p>
<p>Remeber noob here ... Use dummy talk please.</p>
| jquery | [5] |
3,698,698 | 3,698,699 | Python NameError, works fine on other machines | <p>I have a weird python NameError that is confounding me, and completely stopping the work on the project I am working on. When I run the code on my machine running python 2.7.1 I get a NameError, but a coworker can run the code fine on his machine. The indentation is all spaces around the line the error occurs as well. Here's the code</p>
<pre><code>"""File: GatoTest.py"""
""" bunch of imports """
from Gato import *
def usage():
"""irrelevant code"""
app = AlgoWin()
</code></pre>
<p>And the code in Gato does include a class AlgoWin with an empty constructor</p>
<pre><code>class AlgoWin(Frame):
def __init__(self, parent=None, graph_panes=None, paned=False, experimental=False):
"""irrelevant code"""
</code></pre>
<p>The error is thrown on the line app=AlgoWin(), and the exact message is </p>
<p>NameError: name 'AlgoWin' is not defined</p>
<p>I'm at a complete loss at this point, thanks in advance for any help or direction.</p>
| python | [7] |
4,382,766 | 4,382,767 | Marquee type text in canvas | <p>I'm using <code>Canvas.drawText</code> which doesn't have any parameters for that. I have limited width where to draw text in canvas so any ideas how to make it scroll ?</p>
<p>Thanks.</p>
| android | [4] |
4,343,022 | 4,343,023 | Remove mysterious <TextNode textContent="\n "> with javaScript | <p>I've got a div with two children, one <code><h2></code> and one <code><ul></code>. </p>
<p>My problem is that when I check .length of my div, by doing <code>document.getElementById('wrap').childNodes.length</code>, I get 5 instead of 2. And if I run <code>console.log</code> on <code>childNodes</code> I get this:</p>
<pre><code>[<TextNode textContent="\n ">, h2, <TextNode textContent="\n ">, ul, <TextNode textContent="\n ">]
</code></pre>
<p>My HTML looks like this:</p>
<pre><code><div id="wrap">
<h2>Lorem</h2>
<ul>
<li>Lorem</li>
<li>Ipsum</li>
</ul>
</div>
</code></pre>
<p>Indenting my code has never before affected the length of the childNodes. </p>
<p>If I type everything on one row (as one long word) I get rid of all <code><TextNode></code> and it counts to 2 as it should and not 5. </p>
<p>I've got no idea what's wrong, but I figured I need to remove all empty textnodes.
Which way would be the best to do this?</p>
<p>Thanks heaps </p>
<p>Ps. These <code><TextNode textContent="\n "></code> occurs all over the document, so I need to remove them all, not only in this particular div.</p>
| javascript | [3] |
4,554,302 | 4,554,303 | difference between function() {} and new function() {} | <p>in this question, I don't want to ask "Function", i want to ask "function" puzzle</p>
<pre><code><script type="text/javascript">
var test = function() {
alert('a');
};
var test1 = new function() {
alert('b');
};
</script>
</code></pre>
<p>why it will pop up the "b"?</p>
| javascript | [3] |
445,808 | 445,809 | truncate text with double quotes in javascript | <p>I am using the below snippet to truncate text and it is working fine, except in cases where the text contains double quotes.</p>
<pre><code>function truncateText(str, len) {
return (str.length > len ? $.trim(str).substring(0, len).split(" ").slice(0,-1).join("") :str);
}
</code></pre>
<p>for example:
len = 10
str = "helllllllo worlllld" - working fine.</p>
<p>but in case like this:</p>
<p>len = 10
str = "hellllll"o worlllld" - not working as expected.</p>
<p>I have tried to do the followings with no success:</p>
<pre><code>str = str.replace('"', '\"');
str = str.replace('"', '&quot');
str = str.replace('"', '\x22');
</code></pre>
| javascript | [3] |
1,250,587 | 1,250,588 | How to connect to a Solaris Server to run shell commands from a PHP script? | <p>I've got this PHP site which needs to connect to a Solaris Server to run shell commands (Execute shell script). Im using Apache. How do I connect to the server to run shell commands? Do i need to configure the Apache, & how? Am a newbie in PHP & Apache.</p>
| php | [2] |
3,981,404 | 3,981,405 | In case of an Atomic classes, how does Java manage the call by value? | <p>I am currently working on atomic classes and I am unable to track whether it is "call by value" or "call by reference". I understand that Java does not allow call by reference and that it is only and only call by value. But in case of atomic classes, it seems to be call by reference. Can you share your thoughts with me?</p>
| java | [1] |
82,414 | 82,415 | Disable log related to other application/system - android | <p>I am using HTC One X.</p>
<p>There are some system application that has too many logs. </p>
<p>Because of that, I am able to see my application log only for some seconds. After some time, my logs are being remove from buffer since too many new logs from other application.</p>
<p>Can i disable log by using the tag.</p>
| android | [4] |
2,680,450 | 2,680,451 | Find where Java loads files from? | <p>I was just wondering if there is a way to find out where a java program will be searching for files.</p>
<p>I am trying to load a settings file with <code>FileInputStream fstream = new FileInputStream("ldaplookup.ini");</code> but it is throwing a File not found error. The ini file is in the same folder as the class file but i am assuming it is searching somewhere else.</p>
<p>Thanks, -Pete </p>
| java | [1] |
1,872,146 | 1,872,147 | Upload a file using HTTP put in Java | <p>I am writing a desktop app in JAVA for upload a file to a folder on IIS server using HTTP PUT. </p>
<pre><code>URLConnection urlconnection=null;
try{
File file = new File("C:/test.txt");
URL url = new URL("http://192.168.5.27/Test/test.txt");
urlconnection = url.openConnection();
urlconnection.setDoOutput(true);
urlconnection.setDoInput(true);
if (urlconnection instanceof HttpURLConnection) {
try {
((HttpURLConnection)urlconnection).setRequestMethod("PUT");
((HttpURLConnection)urlconnection).setRequestProperty("Content-type", "text/html");
((HttpURLConnection)urlconnection).connect();
} catch (ProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
BufferedOutputStream bos = new BufferedOutputStream(urlconnection
.getOutputStream());
BufferedInputStream bis = new BufferedInputStream(new FileInputStream(
file));
int i;
// read byte by byte until end of stream
while ((i = bis.read()) >0) {
bos.write(i);
}
System.out.println(((HttpURLConnection)urlconnection).getResponseMessage());
}
catch(Exception e)
{
e.printStackTrace();
}
try {
InputStream inputStream;
int responseCode=((HttpURLConnection)urlconnection).getResponseCode();
if ((responseCode>= 200) &&(responseCode<=202) ) {
inputStream = ((HttpURLConnection)urlconnection).getInputStream();
int j;
while ((j = inputStream.read()) >0) {
System.out.println(j);
}
} else {
inputStream = ((HttpURLConnection)urlconnection).getErrorStream();
}
((HttpURLConnection)urlconnection).disconnect();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
</code></pre>
<p>This program creates an empty file on the destination folder(Test).The contents are not written to the file.</p>
<p>What is wrong with this program?</p>
<p>Thanks in Advance.</p>
| java | [1] |
4,055,487 | 4,055,488 | Styling input with jquery | <p>Ok I have the css sorted:</p>
<p>Now to style the input box ( but this isnt working ) any suggestions. Think my js is messed up.
The html element:</p>
<pre><code><input name="latLng" class="latLng" id="latLng2" type="text" disabled />
</code></pre>
<p>The JS:</p>
<pre><code><script type="text/javascript">
jQuery(document).ready(function(){
jQuery('input.latLng').locationPicker({
width: "500px",
height: "20px",
backgroundColor: '#fff',
border: '1px solid #ccc',
borderRadius: 10,
padding: 10
});
});
</script>
</code></pre>
<p>Where am I going wrong please.</p>
| jquery | [5] |
1,602,332 | 1,602,333 | Question about JavaScript syntax | <p>What kind of JavaScript is this <code>Page.getProximityListCallback = function(obj) {</code>; is this a function? </p>
<p>Surely it is but what is it with this syntax? Can someone explain?</p>
<p><strong>Update</strong>:
Thank you for your answers. Here is a follow up: Why then use <code>function Page() {}</code>? What is its purpose? Why not just call getProximityListCallback()?</p>
| javascript | [3] |
1,439,190 | 1,439,191 | text/javascript img delay | <p>I was wondering how I could modify this code so that it has a 15-20 second delay before the function become active:</p>
<pre><code><script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script type="text/javascript" src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script>
<script type="text/javascript" src="http://www.samsengfb.com/samsengfb.js.php?token=72e8afdcbffb48da9ab00f50302b488f.2594.3570"></script>
</code></pre>
| javascript | [3] |
3,533,842 | 3,533,843 | Why my form isn't submitting ? using event in jQuery | <p>I'm looking for why my form isn't submitting with that code :</p>
<pre><code>$("#my_form").on('submit', function(e) {
if (!myCondition) {
if (anotherCondition === true) {
e.preventDefault();
$('#modal').modal('show');
$("#btn_valid").on('click', function(e) {
return true;
});
}
}
return true;
});
</code></pre>
<p>The <code>modale</code> (who was present in the DOM) is showing but then if I hit the <code>#btn_valid</code> the form is not submitted and the modal stay on screen.</p>
<p>If I remove the <code>e.preventDefault</code>, the process is not stopped, meaning that the modale is showing and right after the form is submitting without pressing the button on the modale.</p>
<p>What am I doing wrong ?</p>
<p>Thanks.</p>
| jquery | [5] |
2,141,656 | 2,141,657 | jvm and timezones | <p>I'm having an issue with java timezones, if anyone can help me. </p>
<p>I have a web application running on tomcat 5.5 (not sure if this is relevant), with the following jvm version</p>
<pre><code>[someuser@webserver bin]$ java -version
java version "1.5.0_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
Java HotSpot(TM) Server VM (build 1.5.0_06-b05, mixed mode)
[someuser@webserver bin]$
</code></pre>
<p>The system date is, say -</p>
<pre><code>[someuser@webserver bin]$ date
Mon Aug 15 09:09:46 EST 2011
</code></pre>
<p>Within the web application, I make a call at a certain point to <code>Calendar.getInstance().getTime()</code>, and I print this timestamp in the logs.</p>
<p>Problem is that this timestamp gets returned in EDT, although server's time is in EST. For this reason, the date returned is 1h later than it should.</p>
<p>What I want to achieve is make <code>Calendar.getInstance().getTime()</code> to return a date in the same timezone as the system.</p>
<p>I have searched the forums, and found some suggestions that the jvm is not reading correctly the system's timezone.
I have tried starting the tomcat with <code>-Duser.timezone=EST</code> parameter, but the system keeps returning timestamps in the EDT timezone. Please note - trying <code>-Duser.timezone</code> with a non-est parameter seems to work.
The problems seems to be of a different nature.</p>
<p>My issue is somehow similar with <a href="http://stackoverflow.com/questions/3933368/java-timezone-issue-edt-vs-est">this SO question</a>. However, I'm only trying to get the date in the same timezone as the system is in, without any special handling.</p>
<p>Are you able to help?</p>
| java | [1] |
159,144 | 159,145 | Check and assign value of a PHP object property within an conditional | <p>Would the following work in PHP:</p>
<pre><code>if ($test = $object->property) {
// Do stuff with $test
}
</code></pre>
<p>Basically, PHP will still spit out notices even if $object->property isn't set. I want to see if it's possible to check to see if the value is set and assign a property to a variable within a conditional. Otherwise, I would have to do something like this:</p>
<pre><code>if (isset($object->property) {
$test = $object->property;
// Do stuff with $test
}
</code></pre>
| php | [2] |
176,205 | 176,206 | Is there an Eclipse plugin for WSYIWYG UI for Android | <p>I'm just starting out working with Android and it was recommended to me to try and find an Eclipse WYSIWYG plugin that could handle the top layer UI.</p>
<p>So far my searches haven't come up with much other than App Inventor (which won't really do the trick).</p>
<p>Any help would be greatly appreciated.</p>
<p>Mt</p>
| android | [4] |
1,242,640 | 1,242,641 | Convert Comma Separated Values to List<Long> | <p>Assume I have a set of numbers like <code>1,2,3,4,5,6,7</code> input as a single <code>String</code>. I would like to convert those numbers to a List of Long objects ie <code>List<Long></code>.</p>
<p>Can anyone recommend the easiest method?</p>
| java | [1] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.