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 |
---|---|---|---|---|---|
2,552,171 | 2,552,172 | why do we need both const and non-const getters in this example | <p>I came across this example <a href="http://groups.google.com/group/comp.lang.c++.moderated/browse%5Fthread/thread/d9f7ec296d353943/6626b24459472798?show%5Fdocid=6626b24459472798" rel="nofollow">here</a>:</p>
<pre><code>#include <vector>
#include <cstddef>
template<typename Tag>
class Ref_t {
std::size_t value;
friend Tag& element(Ref_t r, std::vector<Tag>& v) {
return v[r.value];
}
friend const Tag& element(Ref_t r, const std::vector<Tag>& v)
{
return v[r.value];
}
public:
// C'tors, arithmetic operators, assignment
};
struct A{};
struct B{};
typedef Ref_t<A> ARef_t;
typedef Ref_t<B> BRef_t;
int main() {
std::vector<A> va;
ARef_t ar;
A& a = element(ar, va);
}
</code></pre>
<p>So the question is why do we need -two <code>friend element</code> functions in Ref_t class?</p>
| c++ | [6] |
2,570,526 | 2,570,527 | how to change tab of a tabactivity from an activity started by the tabactivity ? or change current tab | <pre><code>public class HMITabActivity extends TabActivity{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final TabHost tabHost = getTabHost();
tabHost.addTab(tabHost.newTabSpec("Tasks")
.setIndicator("Tasks", getResources().getDrawable(R.drawable.program))
.setContent(new Intent(this, Tasks.class)));
tabHost.addTab(tabHost.newTabSpec("HMI")
.setIndicator("HMI")
.setContent(new Intent(this, HMI.class)));
tabHost.addTab(tabHost.newTabSpec("Diagnostics")
.setIndicator("Diagnostics", getResources().getDrawable(R.drawable.diagnostics))
.setContent(new Intent(this, Diagnostics.class)));
tabHost.addTab(tabHost.newTabSpec("About")
.setIndicator("About")
.setContent(new Intent(this, Tasks.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)));
//WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
//Method[] wmMethods = wifiManager.getClass().getDeclaredMethods();
}
</code></pre>
<p>}</p>
<p>how to change the current tab from any of these sub activities (eg: Diagnostics activity).... ??</p>
| android | [4] |
2,874,986 | 2,874,987 | Use PHP to Save Webpage Content on the same URL | <p>I need to use PHP to save a webpage which has content generated in an iFrame, Its like this..</p>
<p>I have a .PHP file with an iFrame (inside which it opens a URL which produces dynamic content) inside it.</p>
<p>I want the Php file to save the generated content (or the whole source) to the server.</p>
<p>I tried the @file_get_contents but how do I specify the URL of the same .php file since it is in iFrame..?</p>
<p>Also how can I output the entire HTTP header into a file with PHP?</p>
<p>I know its a bit unclear but bear with me please!</p>
<p>I tried this code but it doesn't work.</p>
<p>CODE</p>
<pre><code><html>
<body>
<?php
function curPageURL() {
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
return $pageURL;
}
$contents = @file_get_contents($pageURL);
$fp = fopen("file.txt", "a");
fputs($fp, "
$contents
");
fclose($fp);
?>
<iframe src="LINK TO WEBPAGE HERE" />
</body>
</html>
</code></pre>
<p>Thanks</p>
| php | [2] |
675,675 | 675,676 | MediaController positioning over VideoView | <p>I have a VideoView that takes up the top half of the Activity in portrait orientation with the bottom half of the screen showing some images and text. I am playing a rtsp video stream in the video view when the Activity starts. I have attached a MediaController to the VideoView via the following code:</p>
<pre><code> MediaController controller = new MediaController(this);
controller.setAnchorView(this.videoView);
controller.setMediaPlayer(this.videoView);
this.videoView.setMediaController(controller);
</code></pre>
<p>When I tap the VideoView to bring up the MediaController on the screen I expected the playback controls to appear overlaying the bottom area of the VideoView (the bottom of the MediaController even with the bottom of the VideoView). Instead the MediaController pops up lower down on the screen, overlaying some of the graphics and text I have below the VideoView. </p>
<p>Are there some additional steps I need to take to get the MediaController to appear where I want it to on the screen?</p>
| android | [4] |
5,758,159 | 5,758,160 | Regarding Object class function access from a user defined class | <p>We can use base class functions by extending from subclass.Generally we use equals() method which is defined in Object class.I read in the book that every class will extend Object class and so that we are able to use functions like equals() in our user defined class with subclass reference.</p>
<p>One doubt i am having is with out extending Object class (Even any other class that extends Object class) we are able to use equals method.</p>
<p>can any one explain how it happens? </p>
| java | [1] |
4,913,748 | 4,913,749 | eval inside of eval | <p>I am just wondering if there are situations when there are any benefits of using eval function inside of another eval function? Can anyone give an example when one eval function inside of another is actually helpful?</p>
| javascript | [3] |
3,701,776 | 3,701,777 | How to: Layout fixed size components with justified spacing | <p>When I have 1, 2 or 3 components I know how to get them to space properly. But now I have a view that will have 4, 5, ... components in it. Rather than increasing the size of the components (via weight), I need them to remain a fixed size. So... is there any way to lay these out with justified spacing (evenly spaced within the view)?</p>
<p>Thanks,</p>
<p>J</p>
| android | [4] |
1,381,570 | 1,381,571 | How to respect network use settings in Android | <p>My app performs some backgound data collection and I'm adding support for the user network preferences, such as performing background updates and data roaming. I have the following checks already:</p>
<pre><code>ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
if(cm.getBackgroundDataSetting()) {
...
NetworkInfo networkInfo = cm.getActiveNetworkInfo();
if (networkInfo != null && networkInfo.isAvailable() && networkInfo.isConnected()) {
</code></pre>
<p>with the required entries in the manifest:</p>
<pre><code><uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission>
</code></pre>
<p>This all appears to be working fine, but I was wondering if I should be checking anything else? I was worried about checking for data roaming but the <a href="http://developer.android.com/reference/android/net/NetworkInfo.html#isAvailable%28%29" rel="nofollow">docs</a> state that <code>networkInfo.isAvailable()</code> checks this for me. So are there any other checks I need to implement for network settings? Anything else in this area I should be aware of?</p>
| android | [4] |
1,282,211 | 1,282,212 | Join two arrays in Java? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/80476/how-to-concatenate-two-arrays-in-java">How to concatenate two arrays in Java?</a> </p>
</blockquote>
<p>I have two objects</p>
<pre><code>HealthMessage[] healthMessages1;
HealthMessage[] healthMessages2;
HealthMessage[] healthMessagesAll;
healthMessages1 = x.getHealth( );
healthMessages2 = y.getHealth( );
</code></pre>
<p>How should I join the two objects, so I can return only one:</p>
<pre><code>return healthMessagesAll;
</code></pre>
<p>What's the recommended way?</p>
| java | [1] |
5,650,602 | 5,650,603 | get session in php page | <p>how can i get all the SESSION variables in a particular php page?</p>
| php | [2] |
1,256,452 | 1,256,453 | How to create Message List Screen? | <p>I want to create the User interface in which contains Image Button, textbox and button at bottom. Title and label at the top of the screen and whenever user type and clicks the button I want to show entered text in rectangle with some color background like the floating bubble. When user enters another text then again i have to update the screen with entered text with another color in another rectangle with the timestamp at top of rectangle. So if first rectangle is inserted at left side then another should be shown at right side. My question is which layout should I use and how can I draw the rectangle and set background color? Rectangle should have arrow like in MSword Rectangle callout. Also I want to add scroll bar.</p>
<p>Thanks & Regards,
Devyani</p>
| android | [4] |
282,740 | 282,741 | What data type should I use to represent money in C#? | <p>In C#, what data type should I use to represent monetary amounts? Decimal? Float? Double? I want to take in consideration: precision, rounding, etc.</p>
| c# | [0] |
872,308 | 872,309 | What is the significance of single quotes vs double quotes in comparisons? | <p>This returns an error:</p>
<pre><code>return (arg[0] == "-" && arg[1] == "-") ? true : false;
</code></pre>
<p><em>error: ISO C++ forbids comparison between pointer and integer</em></p>
<p>However, this does not:</p>
<pre><code>return (arg[0] == '-' && arg[1] == '-') ? true : false;
</code></pre>
<p>What is the difference between <code>'</code> and <code>"</code> ? </p>
| c++ | [6] |
3,703,810 | 3,703,811 | Can Dynamic Array be used only in classes and struct? | <p>can anyone pliz let me know what am i doing wring in the following code. Also pliz let me know if this method only works with classes and struct? I was trying to solve this using one dim array but was not successful. Using structs to compile this also seems challenging. Any help will be appreciated.Kind Regards</p>
<pre><code> /*
The text file looks like this:
2
ID MARK
S11 10
S22 20
*/
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
struct student
{
string id;
int mark;
};
void discard(ifstream &inp);//function to discard lines in text files
int main()
{
//varaible declaration
char c;
string read;//to read the number of students in the text file
int total_rec; //to record the number of students in the text file
student *studinfo;
ifstream input;
input.open("c:\\students.txt");
input >> read >> total_rec;
studinfo = new student[total_rec]; //new dyanamic array
student *studptr = studinfo;
discard(input);//discarding two tiltles in the text files
discard(input);
while(!input.eof())
{
input >> studptr[total_rec].id >> studptr[total_rec].mark;
total_rec++;
studptr++;
input.get(c);
}
studptr = studinfo; //making studptr point back to where it started
//prinitng the information in the text file
for (int i = 0;i<total_rec;i++)
{
cout << studptr[i].id << " " << studptr[i].mark;
cout << endl;
}
studptr = studinfo;
delete [] studptr; //deallocating memomory from heap
system("pause");
return 0;
}
void discard(ifstream &inp)
{
char c;
do
inp.get(c);
while(c!='\n');
}
</code></pre>
| c++ | [6] |
32,949 | 32,950 | When would I use an alias on a using Directive? | <p>So I was reading over the MSDN docs and came across:</p>
<p><a href="http://msdn.microsoft.com/en-us/library/sf0df423.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/sf0df423.aspx</a></p>
<p>What is a practical use of using an alias for <code>using</code> directives? </p>
<p>I get what is does, I just dont get WHY I could want to use it.</p>
| c# | [0] |
5,918,352 | 5,918,353 | Browse Server Folders in Client | <p>I have a requirement for an admin user to set up an export directory on the web server, or relative to the web server using a UNC. Is there anything already out there that I can use for this, or must I recurs a limited directories and populate a home-rolled directory browser on the client?</p>
| asp.net | [9] |
4,979,288 | 4,979,289 | C# code to Import Excel data in to SQL server 2008 | <p>My question which is the best approach to import the data from Excel to SQL server 2008. It has lots of check like duplicates check etc.,</p>
<p>I would say we have </p>
<p>1.Import Export wizard<br>
2.SSIS package<br>
3.Create a .NET Console App with inline query<br>
4.Create a .NET console app with stored proc because it has lots of checking conditions. </p>
<p>Which is the best approach?</p>
<p>thanks in advance</p>
| c# | [0] |
2,141,024 | 2,141,025 | How to push text into newly created file by shell script from PHP? | <p>i used PHP site to run a shell script and it created my desired name file "result.txt" inside /opt/xampp/htdocs. However, the result.txt is totally empty, when it is supposed to have output values from the shell script. Tried on terminal, result.txt is created on Desktop and outputs are there. Tried on PHP, result.txt is created but totally no outputs are inside.</p>
<p>It's a long script so here's the first few lines:</p>
<pre><code># creates result.txt
touch result.txt
##makes the .txt read only
chmod 444 result.txt
clear
###################################################
# This option audits the password and #
# shadow files on the system #
###################################################
##option 2.1.1
echo -e "=========================================================================================" >> result.txt
echo " SHADOWED PASSWORD CHECK " >> result.txt
echo "=========================================================================================" >> result.txt
</code></pre>
<p>Anyone? </p>
<p>Thanks.</p>
| php | [2] |
1,438,511 | 1,438,512 | var_dump and simpleXML? | <p>I'm loading an XML file in via simpleXML. I'm a novice at best at PHP and new to parsing PHP but I'm a little confused</p>
<p>I'm trying to understand the structure of the variable I have stored, so I tried var_dump()</p>
<p>The thing that's confusing me is the data I'm looking for that's in the XML is <em>not</em> anywhere in the dumped data</p>
<p><a href="http://gdata.youtube.com/feeds/api/videos?q=surfing&max-results=25" rel="nofollow">http://gdata.youtube.com/feeds/api/videos?q=surfing&max-results=25</a></p>
<p>That's the URL I'm using at the moment. However, for example, the duration/seconds is nowhere to be found in the dumped variable data-- where is it and how do I access it?</p>
<p>here is the output I'm getting: <a href="http://pastebin.com/ggumXTEu" rel="nofollow">http://pastebin.com/ggumXTEu</a></p>
| php | [2] |
2,860,672 | 2,860,673 | Only replace own website url in text with HTML links | <p>When user post a comment, i strip all the html tags in the comment before insert into my database because i do not want them to post external links(SPAM) in the comment. But i only want to strip external links, i want to display my own website URL as normal clickable links. How to detect the URL is my own website's URL and make it clickable as usual? </p>
<p>Example in the comment:
Blah... blah... blah... <a href="http://my_website_url.com" rel="nofollow">http://my_website_url.com</a> Blah... blah... blah... Blah... blah... blah... Blah... blah... blah... Blah... blah... blah... Blah... blah... blah...http://external_links.com Blah... blah... blah... Blah... blah... blah... </p>
<p>As above example, i want ONLY <a href="http://my_website_url.com" rel="nofollow">http://my_website_url.com</a> become clickable link before insert into my database. (http://my_website_url.com to < a href="http://my_website_url.com" >http://my_website_url.com< /a > )</p>
<p>Also, not only detect the main URL:http://my_website_url.com, but also:</p>
<p>-http://www.my_website_url.com</p>
<p>-www.my_website_url.com</p>
<p>-my_website_url.com</p>
<p>-http://my_website_url.com/blah/blah/blah</p>
<p>-http://www.my_website_url.com/blah/blah/blah</p>
<p>-www.my_website_url.com/blah/blah/blah</p>
<p>-my_website_url.com/blah/blah/blah</p>
<p>or any URLs that from my website:http://www.my_website_url.com/xxx/xxx/xxx/xxx</p>
<p>If could, please post exactly php codes to let me copy and paste into my file because i have little knowledge with php only. Thanks guys. :) </p>
| php | [2] |
3,587,005 | 3,587,006 | Passing PHP form variables from one page to other | <p>my php configuration on server are showing i can post variables to maximum size upto 8MB , thats enough .. but how to check for number of variables , sever is running ubuntu 4.4 , php .</p>
<p>i have a page which takes students marks and send them to a action page , but on action page doing echo for the post variables nothing is being displayed , where are doing an echo "hello"; this shows ...</p>
<p>this is the page which sends the variables </p>
<pre><code><form name="frm" action="marklistI.php" method="POST" class="" >
<?php $tb->displayTable() ?>
<div class="mainframe">
<input type="hidden" name="batch" value="<?php print $_GET['batch']; ?>"/>
<input type="hidden" name="sem" value="<?php print $_GET['sem']; ?>" />
<input type="hidden" name="chance" value="<?php print $_GET['chance']; ?>"/>
<input name="submit" type="submit" class="hide" value="Save"/>
<input type="hidden" name="url" value="<?php print $_SERVER['REQUEST_URI']; ?>"/>
</div>
</form>
</code></pre>
<p>and this are the variables are coming to action page .. but on echo they are not showing any value .</p>
<pre><code>$dept =$_COOKIE['dept'];
$join=$_POST['batch'];
$type='e';
$sem=$_POST['sem'];
$chance=$_POST['chance'];
</code></pre>
| php | [2] |
5,826,943 | 5,826,944 | Specifying a parameter in C#'s OrderBy methods | <p>Good morning,</p>
<p>Let's imagine I have a list of Tuple elements, and a function taking a String and returning a Double, for example. How can I, from some other method, use the list's <code>OrderBy</code> method with that function calculated only on the first coordinate of each tuple? For example, <code>return List.OrderBy(FunctionTakingString(Tuple'sFirstCoordinate)).First</code> ?</p>
<p>Thank you very much.</p>
| c# | [0] |
4,452,492 | 4,452,493 | Android: How do I use the volume buttons to initialize an app? | <p>I'm like working on an app that will call home when I press down the volume. </p>
<p>I have a working Dial / Call method. Now I need help figuring out how to get it all encapsulated in a method that will activate when the volume key down is pressed and held. </p>
<p>Any advice would help immensely.</p>
| android | [4] |
3,782,218 | 3,782,219 | ASP.NET: Highlight menu item of current page | <p>I've been trying to find an easy way of highlighting the current selected menu item of an asp.net menu (so the user knows which page they are on), but no matter what I have tried I can't get it to work. In my markup I have:</p>
<pre><code><asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" EnableViewState="false" IncludeStyleBlock="false" Orientation="Horizontal" StaticSelectedStyle-ForeColor="#99CCFF" DynamicSelectedStyle-ForeColor="#99CCFF">
<Items>
<asp:MenuItem NavigateUrl="~/Default.aspx" Text="Operations"/>
<asp:MenuItem NavigateUrl="~/Analysis.aspx" Text="Analysis"/>
<asp:MenuItem NavigateUrl="~/Dashboard.aspx" Text="Dashboard"/>
<asp:MenuItem NavigateUrl="~/Flashboard.aspx" Text="Flashboard"/>
<asp:MenuItem NavigateUrl="~/Spacequest.aspx" Text="SQ OBP"/>
</Items>
</asp:Menu>
</code></pre>
<p>And in the server side Page_Load function:</p>
<pre><code>((Menu)Master.FindControl("NavigationMenu")).Items[0].Selected = true;
</code></pre>
<p>But this does not work. I tried using a sitemap (even though a sitemap is not what I want to use) and that hasn't worked either. Any ideas?</p>
| asp.net | [9] |
2,275,525 | 2,275,526 | Is there any command to enable/disable a php extension from command line? | <p>Is there any command to enable/disable a php extension easily from command line? (php.ini)</p>
| php | [2] |
2,338,017 | 2,338,018 | unexpected T_DOUBLE_ARROW when referring to an Array | <p>I think its because I am not referring to the array properly. I'm new to PHP so I faced this error.</p>
<p>On this line <code>$this->fields['id'] => &$doc->id;</code></p>
<p><strong>Code is given for reference:</strong></p>
<pre><code><?php
class Zoho{
public $fields;
public function __construct(){
$this->fields = array(
// 'content' => "@/wamp/apps/researchportal/tmp/a.doc",
'apikey' => $this->api_key,
'output' => $this->output,
// 'id' => time(),
// 'filename' => $usr_bin.'_!@#$%^&^%$#@'.$usr_doc,
// 'format' => $ext,
'saveurl' => $this->save_url = $save_url,
'mode' => $this->mode
);
}
public function viewDocument(&$doc) {
$this->fields['id'] => &$doc->id;
$this->fields['filename'] => &$doc->doc_name;
$this->fields['format'] => &$doc->doc_ext;
$this->fields['mode']='view';
$this->fields['content']='@'.&$doc->path;
}
}
$document = new Document('C:/wamp/apps/researchportal/tmp/qubee.doc');
$zoho_s = new Zoho('http://133.223.121.12/researchportal/common/save.php');
$zoho->viewDocument();
?>
</code></pre>
| php | [2] |
1,118,060 | 1,118,061 | How to make a 3D object array in JavaScript? | <pre><code>lyricsInp = document.getElementById("lyrics").value;
var lines = lyricsInp.split("\n");
for (i = 0; i < lines.length; i++) {
holder[0][i] = new Array();
words = lines[i].replace(/[ \t\r]+/g, "###").split("###");
for (j = 0; j < words.length; j++) {
holder[0][i][j].word = words[j];
holder[0][i][j].startT = 0;
holder[0][i][j].endT = 0;
}
}
</code></pre>
<p>Here I need each holder element to keep <code>word,</code> <code>startT</code> and <code>endT</code>, but this does not work. How do I make this happen.</p>
| javascript | [3] |
3,285,179 | 3,285,180 | Why does this keep going around in a never ending loop? | <pre><code>def get_houseid_list():
"""Returns a list of all house ids from db"""
print 'Building list of all HouseIDs...'
houseid_list = []
houseids = session.query(Episode.HouseID).all()
for i in houseids:
houseid_list.append(i[0])
return houseid_list
def walkDir(top, ignore=[]):
"""Returns a complete list of files from a directory, recursing through subfolders"""
print 'Building list of files...'
fflist = []
for root, dirs, files in os.walk(top):
dirs[:] = [ dn for dn in dirs if dn not in ignore ]
file_list = [name for name in files if name[0] != '.']
if len(file_list):
for f in file_list:
try:
houseid_parse(f)
print 'adding...', f
[fflist.append(join(root, f)) for f in file_list]
except HouseIdException:
print 'skipping...', f
print 'Found', len(file_list), 'files in', root
return fflist
def get_nonmatches(houseid_list, finallist):
print 'Comparing files to HouseIDs...'
nonmatches = []
for id in houseid_list:
print 'Searching for files to match', id
for f in finallist:
if re.search(id, f, re.IGNORECASE):
nonmatches.append(f)
return nonmatches
def writeCSV(nonmatch):
print 'Writing nonmatches to CSV...'
csv.write('%s' % nonmatch)
if __name__ == "__main__":
houseid_list = get_houseid_list()
print len(houseid_list), 'HouseIDs found'
wdirs = ['/Volumes/Assets/Projects']
finallist = []
for d in wdirs:
fflist = walkDir(d)
for f in fflist:
nonmatches = get_nonmatches(houseid_list,f)
print 'nonmatches', nonmatches
</code></pre>
| python | [7] |
1,878,384 | 1,878,385 | Is there a way to only pass a certain variable and it's value with the include function? | <p>I want to include a page that contains a variable with a value that I need to insert in a database, but when I include the page, functions out of the scope of the second page try to run, which leads to an undefined error. </p>
<p>Basically I want this:</p>
<pre><code>mainpage.php
<?php
$variable = 'value';
function();
?>
</code></pre>
<p>secondpage.php</p>
<pre><code> <?php
include 'mainpage.php';
echo $variable;
?>
</code></pre>
<p>But I cant do this without also calling the function. </p>
| php | [2] |
3,416,432 | 3,416,433 | I cannot close my launcher app after startup | <p>My application works as a launcher and also it starts on startup. However, something is wrong with it. For instance, I install my application on device, and open it by selecting Always button (as default launcher). There is no problem until here. However, if I reboot my device (it opens on startup, as I said before), the application opens. But when I want to close it, I cannot do that. It opens again.<br /><br />
This is my Manifest file:<br /></p>
<pre><code><receiver android:enabled="true" android:name=".BootUpReceiver"
android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
<activity
android:name="com.comeks.cocuktablet.Main"
android:label="@string/app_name"
android:launchMode="singleInstance"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</code></pre>
<p><br />
This is <strong>BootUpReceiver.java</strong>:<br /></p>
<pre><code>public class BootUpReceiver extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent) {
if(intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)){
Intent i = new Intent(context, Main.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}
}
}
</code></pre>
| android | [4] |
3,145,442 | 3,145,443 | can you please help me am very new to java and i have this assignment | <p>Write a Java program to read N integers from the keyboard and store them into a file
“mynumbers.dat”. Reading should stop when zero is entered. Your program should then
perform the following operations on the set of integers entered:</p>
<ol>
<li><p>Remove redundant elements</p></li>
<li><p>Sort the elements entered in ascending order</p></li>
<li><p>Store the redundancy-free sorted elements in another file “mysortednumbers.dat”</p></li>
<li><p>Display the maximum, the minimum, the mean and median of the elements in (c)</p></li>
</ol>
| java | [1] |
4,834,861 | 4,834,862 | Centering an element to the viewable area with Jquery | <p>I have a huge scrollable area. In one section I have a grid of thumbnails. When clicked, the thumb is cloned and animates out to the center of the screen, but it animates to the center of the entire area, not the area that you are viewing i;e, the area of have scrolled to. How can I get it to animate to the center of the viewable area? JQuery Code is as follows:</p>
<pre><code>var $article = $('#news-articles .news-article').eq(index);
var $articleClone = $article.clone(true); // clone the article for the corresponding link
// Create the expanded item container
var $expandedItem = $('<div>', {
id: 'item-expanded',
css: {
width: 188,
height: 188,
background: '#fff',
position: 'absolute',
zIndex: 999
},
});
$expandedItem.append($img); //Add the cloned image to the expanded item container
$('body').append($expandedItem); //Add the shaded overlay and the expanded item to the body
//Animate the size of the expanded item
$expandedItem.animate({
width: 400,
height: 400,
left: $(window).width()/2,
top: $(window).height()/2,
marginTop: -400/2,
marginLeft: -400/2,
}, {
duration: DDBR.constant.ITEM_ANIMATION_SPEED,
easing: DDBR.constant.ITEM_ANIMATION_EASING,
queue: false,
complete: function() {
animFinished = true;
if (animFinished) {
imageFade();
}
}
});
</code></pre>
<p>Please note that I have tried changing the positioning of $expanded item to 'fixed'. However, this creates a problem as it needs to animate from the position of the clicked thumbnail which I obtain using the thumb's 'offset'. Changing the positioning of $expandedItem causes it to animate from the thumb's position when it is first loaded, not it's current position after the page has been scrolled.</p>
<p>Hope it all makes sense. Any help with this would be greatly appreciated.</p>
<p>Thanks in advance.</p>
| jquery | [5] |
5,131,422 | 5,131,423 | Can I create multiple dlls from one project? | <p>I have a very large website which was "published" using Visual Studio 2008 to the dev/live server. As a result, there are no *.aspx.cs files on the live server, just "website.dll" - all good so far.</p>
<p>However, because we're constantly having to add pages to the site this now means that if I'm half way through developing a big part of the site when I'm required to make a small change elsewhere, I can't publish "website.dll" to the live site because it has all my half finished code in there. How do people deal with this situation?</p>
<p>If I could split the site up into multiple dlls (perhaps based on namespace?) then I could just publish the small part of the site that's changed, leaving the bit I'm still developing on the dev server.</p>
<p>Thanks,</p>
<p>B</p>
| c# | [0] |
434,368 | 434,369 | How to overwrite a HashSet element in Java while iterating over it | <p>Is it possible to overwrite some HashSet element (not necessarily the one iterated) while iterating over it. I want to know of a way apart from removing, editing and then re-adding it?
The reason I am asking this is because using remove while iterating always gives the java.util.ConcurrentModificationException. I figured out that there is no method to overwrite a set element.</p>
<p>Any help will be appreciated.</p>
<p>Thanks,</p>
<p>Somnath </p>
| java | [1] |
587,422 | 587,423 | Refresh tableLayout | <p>Hi I have a tableLayout and am populating the layout with ImageView[][] using a nested for loop. I'm currently trying to click on an ImageView and rearrange the ImageView[][] data then refresh the screen to reflect the rearrangement. Is there a way to do this? Apparently I can't call the setContentView more than once.</p>
<p>Edit: you can see this is the code for the onclick event. I setContentView of the original TableLayout ('tl') in the onCreate event and can't call it again here. </p>
<pre><code>public void onClick(View v) {
// TODO Auto-generated method stub
switch(v.getId()){
case 1:
image_array = switchTile(image_array, 2,1,0,0);
Toast.makeText(this, "1 clicked!", Toast.LENGTH_LONG).show();
}
tl.removeAllViewsInLayout();
for(int i = 0; i < level; i++){
TableRow new_tr = new TableRow(this);
new_tr.setLayoutParams(layout_image);
for(int j = 0; j< level; j++){
new_tr.addView(image_array[i][j]);
}
tl.addView(new_tr);
}
tl.invalidate();
}
</code></pre>
| android | [4] |
2,667,891 | 2,667,892 | imeOptions actionDone with Android 2.3 | <p>I have a few EditTexts where I've set the imeOptions to actionDone. When I run my application in the emulator using either Android 2.1 or Android 2.2, the enter key on the virtual keyboard becomes "done."</p>
<p>However, (and I've not tested this in the emulator), when I run my application on my phone, which is running Android 2.3 (straight 2.3, Nexus S), the enter key on the virtual keyboard is still a return button and pressing it enters a newline into the EditText.</p>
<p>How can I make the return key on the virtual keyboard say and behave as "done" in Android 2.3?</p>
| android | [4] |
2,075,217 | 2,075,218 | Fastest way to test if N milliseconds is elapsed from some event | <p>I'm writing udp multicast datagrams receiver.</p>
<p>If I receive datagram with number X and datagram "X-1" still not received I should wait for 5 ms (because UDP doesn't garantee order of packets) and if datagram "X-1" still not received I should recover.</p>
<p>How to do that? I want to store for each received packet in array the "timestamp" when packet is received. later I want to compare current time with timestamp, and if difference is more than 5 ms and packet X-1 is missing I should recover.</p>
<p>Probably you can suggest another algorithm?</p>
<p>Or if mine is fine how can I convert "current time" to "int" or "long" milliseconds? I don't want to use <code>DateTime.Now</code> object because it contains a lot of garbage I don't need and I need to do this processing several thousands times per second.</p>
| c# | [0] |
2,570,041 | 2,570,042 | how can i prevent the get url to show text or random text instead | <p>eg, $search = $_GET[$id];</p>
<p>instead of showing website.com/result.php?find=56</p>
<p>it would be website.com/result.php?find=sometext</p>
<p>in the db 56 is the id and sometext is the title how can i get the title to show instead when i use the get url id function</p>
| php | [2] |
1,851,661 | 1,851,662 | realtime update text in javascript by same id | <p>How do I update the text in the id="b"?</p>
<pre><code><script type="text/javascript">
function updateb()
{
var a= document.getElementById("a").value;
var b = document.getElementById("b").innerHTML = a * 10;
}
</script>
<input type="text" id="a" name="a" value="10" onKeyUp="updateb();" /><p id="b" name="b"></p>
<input type="text" id="a" name="a" value="20" onKeyUp="updateb();" /><p id="b" name="b"></p>
<input type="text" id="a" name="a" value="30" onKeyUp="updateb();" /><p id="b" name="b"></p>
</code></pre>
| javascript | [3] |
2,187,341 | 2,187,342 | Why Screen is blinking when I am moving Object? | <p>I need to move object on screen, but when the object is moving the Screen is blinking (and the object too).</p>
<p>How can I fix it ? What is the best way to move an object on screen ?</p>
<p>Thanks in advance</p>
| c# | [0] |
1,572,268 | 1,572,269 | How to represent "1\0" + "2" as a single string in javascript? | <p>Given the code below:</p>
<pre><code>alert(encodeURIComponent("1\0" + "2")); // shows 1%002
alert(encodeURIComponent("1\02")); // shows 1%02
</code></pre>
<p>Why is there a difference in the output?</p>
| javascript | [3] |
2,413,411 | 2,413,412 | malloc: *** error for object 0x1001002e0: pointer being freed was not allocated | <p>please
help me I am running the code of api microtik, but I have this error</p>
<pre><code> malloc: *** error for object 0x1001002e0: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
</code></pre>
<p>any body could help me?</p>
| c++ | [6] |
4,170,793 | 4,170,794 | Reading from set possition in binary file (java) | <p>I am making a small program in java, and i want it to read from a set position in a binary file. Like substring only on file streams. Any good way to do this?</p>
<pre><code>byte[] buffer = new byte[1024];
FileInputStream in = new FileInputStream("test.bin");
while (bytesRead != -1) {
int bytesRead = inn.read(buffer, 0 , buffer.length);
}
in.close();
</code></pre>
| java | [1] |
684,385 | 684,386 | Animate a shape's property | <p>I wanna make a normal shape say a rectangle (scaleable and animatable) in some properties and draw it on canvas.</p>
<p>e.g. Transform height from 50 to 100, Transform color red to blue (using the diff of RGB) and scale it by different interpolator. </p>
<p>Should I extends ShapeDrawable and implements animatable and do my own scaling?</p>
<p>Or should I add a shape in AnimationDrawable and dynamically create shapes in the frames?</p>
<p>Or Is there something already done</p>
<p>(I am targeting 2.x+ platform)</p>
<p>Thanks in advance</p>
| android | [4] |
145,093 | 145,094 | Splitting a string by capital letters | <p>I currently have the following code, which finds capital letters in a string 'formula': <a href="http://pastebin.com/syRQnqCP" rel="nofollow">http://pastebin.com/syRQnqCP</a></p>
<p>Now, my question is, how can I alter that code (Disregard the bit within the "if choice = 1:" loop) so that each part of that newly broken up string is put into it's own variable?</p>
<p>For example, putting in NaBr would result in the string being broken into "Na" and "Br". I need to put those in separate variables so I can look them up in my CSV file.
Preferably it'd be a kind of generated thing, so if there are 3 elements, like MgSO4, O would be put into a separate variable like Mg and S would be.</p>
<p>If this is unclear, let me know and I'll try and make it a bit more comprehensible... No way of doing so comes to mind currently, though. :(</p>
<p>EDIT: Relevant pieces of code:</p>
<p>Function:</p>
<pre><code>def split_uppercase(string):
x=''
for i in string:
if i.isupper(): x+=' %s' %i
else: x+=i
return x.strip()
</code></pre>
<p>String entry and lookup: </p>
<pre><code>formula = raw_input("Enter formula: ")
upper = split_uppercase(formula)
#Pull in data from form.csv
weight1 = float(formul_data.get(element1.lower()))
weight2 = float(formul_data.get(element2.lower()))
weight3 = float(formul_data.get(element3.lower()))
weightSum = weight1 + weight2 + weight3
print "Total weight =", weightSum
</code></pre>
| python | [7] |
5,051,118 | 5,051,119 | php strong ban system based on ip address | <p>I have a social networking website I want build a banning system based on ip address. About how we can control a user with dynamic ip address? If I will block user based on account he/she can create new account. What will be best solution? </p>
| php | [2] |
5,267,384 | 5,267,385 | password storeage and retrieval | <p>when using password and id they would have to be stored in a file . not in the source code. how does one store and retrieve the pass codes. all i have seen is input boxes. are the files random access or other type files? One has to have a way to store and retrieve over a million pass and id's </p>
| javascript | [3] |
4,116,364 | 4,116,365 | Why single var is good in javascript? | <p>Can anyone tell me why use one var declaration for multiple variables and declare each variable on a newline consider is a good programming behavior?</p>
<pre><code>// bad
var items = getItems();
var goSportsTeam = true;
var dragonball = 'z';
// good
var items = getItems(),
goSportsTeam = true,
dragonball = 'z';
</code></pre>
| javascript | [3] |
426,536 | 426,537 | Sending select option with jquery to a php file...? | <p>I have looked for 2 days to find out how to send a variable with jquery to php. I have searched for over 100 posts on stackoverflow, i tried multiple examples. But i just get it done. So i really hope someone over here would be kind enough to help me find out what i am doing wrong....</p>
<pre><code><?php
print_r(json_decode($_POST['country']));
?>
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
$('#country').change(function() {
var country = $('#country').val();
$.ajax({
type: 'POST',
data: country,
dataType: 'json',
url: 'timezone/timezone.php',
})
alert("Country: " + country);
});
});
</script>
</head>
<body>
<form method = "post" name="form1">
<select name="country" class="country" id="country">
<option value="NL">Nederland</option>
<option value="BE">Belgie</option>
</select>
</form>
</body>
</html>
</code></pre>
| jquery | [5] |
5,711,362 | 5,711,363 | How to always start from a startup activity on Android? | <p>There are three different cases:</p>
<p>1) A user launches an app, navigates in it, pressed home and click on the app icon again to launch our app again.</p>
<p>2) A user launches an app, navigates in it, presses home, chooses recent and click on the app to launch our app again.</p>
<p>3) A user launches an app, navigates in it, click something in the app (TextView with a link), which calls another app (as example Email) and user clicks back button, which bring us back to our app.</p>
<p>I know about flag "clearTaskOnLaunch" flag, it solves case #1.</p>
<p>I know about about flag "excludeFromRecents", it solves case #2 (may be not the most user friendly solution, but it works).</p>
<p>What about case #3? I have a workaround right now. However, I will have to put it on all activities which can be lead to another app. I wonder, whether there is better way to solve it (without handling it in all such activities).</p>
| android | [4] |
619,957 | 619,958 | send message from desktop server to client android using JSON file? | <p>in android, how to make connection between client android and desktop server using http and put timer that check for requested URL and the server send message in JSON file to client android then in client android will parser JSON file and get the message that the server send it </p>
| android | [4] |
2,787,685 | 2,787,686 | How to check if my application is running in android(not as a service)? | <p><strong>Problem:</strong>
I have to check if my app is running or not(when a service is already running in background). Based on it I am suppose to either start particular activity or the app.</p>
<p><strong>Thing I tried or come up with but failed</strong>
I tried to check current running process and based on it tried to decide if app is running or not.
Reason for failure: Get app running status as always true since I already had service running in background.</p>
<p><strong>Possible solution but not sure if that possible in android</strong>
1. If we can run service by different name(package name)
2. Set some boolean value to true and false on app start and close respectively. But is this a good approach?</p>
<p><strong>EDIT::</strong></p>
<p>Sorry if I wasn't very descriptive earlier. I try to explain you what exactly I'm trying to acheive.</p>
<p>Whenever user click on notification. I have to do any one out of two option after checking if my app is launched(excluding services since they are always running in the background).
1. If my app is already launched just start the required activity.
2. If app is not launched then I have to launch it and then open the required activity.</p>
<p>e.g
I get a message arrival notification. If my application is launched I have to show inbox otherwise I have to launch my application and then open the inbox.</p>
| android | [4] |
5,992,846 | 5,992,847 | Add UIToolbar to UIViewController | <p>How to add <code>UIToolbar</code> to the below <code>UIViewController</code>.</p>
<pre><code>PageOneViewController *viewController = [[PageOneViewController alloc] init];
[self presentModalViewController:viewController animated:YES];
[viewController release];
</code></pre>
<p>This <code>UIViewController</code> is the view of the <code>mainviewcontroller</code> and <code>UIToolbar</code> is in the <code>mainviewcontroller</code>. So basically when this view is loaded i want <code>UIToolbar</code> to load as well. </p>
<p>Can someone give me an idea </p>
| iphone | [8] |
4,560,938 | 4,560,939 | iPhone: iOS 4.3 SDK Simulators stuck up and crashing: | <p>I have updated my Mac to 10.6.7 with Xcode 4. I am trying to build and run some projects which has downloaded from Internet. I set the deployment target as 4.1/4.2/4.3 and device family as 'iPhone' and trying to build and run the application in Simulator. For ex: i downloaded a project from the following link from GitHub:
<a href="http://www.icodeblog.com/2010/10/07/cloning-uiimagepickercontroller-using-the-assets-library-framework/" rel="nofollow">http://www.icodeblog.com/2010/10/07/cloning-uiimagepickercontroller-using-the-assets-library-framework/</a></p>
<p>I set the deployment target as 4.1 or 4.2 or 4.3 and device family as 'iPhone' and trying to build and run the application in Simulator. But Simulator launches and stuck up infinitely. I had to do force quit of simulator, i checked so many times, but the same result. But at the same time, i'm able to build and run some other my projects without any issues. This is happening only for few projects when i run.
What could be the reason here? Is there any settings that i need to make-up?</p>
<p>Please advise me.</p>
<p>Thank you in Advance!</p>
| iphone | [8] |
5,302,229 | 5,302,230 | What is the best way and approach to start learning Android | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/2869338/where-to-start-to-learn-android">Where to start to learn Android?</a> </p>
</blockquote>
<p>Hello,</p>
<p>I am going to start learning android. I want to know from all those Android Developers as to what is the best way to start learning Android. How can one start from complete novice to become an Android Master. </p>
<p>How can I learn best practices in Android Development.</p>
<p>Thanks in advance.</p>
| android | [4] |
4,063,174 | 4,063,175 | How to avoid memory leak in handler? | <p>My library code will notify byte array to UI,which in turn queued.Another thread will dequeue the byte array and using an instance of handler bundle the byte array and send message to update UI.</p>
<p>code snippet which use handler to update UI</p>
<pre><code>public void run(){
while(running){
try {
byte[] msg=(byte[]) queue.getMsg();
Message message=new Message();
Bundle bundle=new Bundle();
bundle.putByteArray("img",msg);
message.obj=bundle;
handler.sendMessage(message);
message=null;
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
</code></pre>
<p>but the thing is i am getting outofmemory exception after 5 to 10 minutes.
Using Eclipse MAT heap dumps shows 90% of heap is occupied by the more instance of android.os.Message.</p>
| android | [4] |
3,963,887 | 3,963,888 | Compare the lengths arrays that have duplicates | <p>I wish to determine whether there are any duplicates in two arrays, i.e. duplicates in array1 or duplicates in array2. If there are, then set a variable to equal 1, otherwise 0. I have the following code but it does not seem to work and I cannot understand why:</p>
<pre><code>$a = count(array_unique($myarraydf));
$b = count($myarraydf);
$c = count(array_unique($myarrayds));
$d = count($myarrayds);
if (($a == $b) || ($c == $d)) {
$ties = 0;
}
else {
$ties = 1;
}
</code></pre>
<p>where $myarraydf and $myarrayds are arrays of numeric values.</p>
| php | [2] |
3,550,715 | 3,550,716 | How can I separate a number and get the first two digits in PHP? | <p>How can I separate a number and get the first two digits in PHP?</p>
<p>For example: <code>1345</code> -> I want this output=> <code>13</code> or <code>1542</code> I want <code>15</code>.</p>
| php | [2] |
1,176,048 | 1,176,049 | android honeycomb list menus | <p>I feel stupid for asking: What are the drop menus on honeycomb apps called? I'd like to use them in my app but i don't even know where to start.</p>
<p>An Example from Google Music, notice the triangle in the corner:</p>
<p><img src="http://i.stack.imgur.com/WUxEh.png" alt="unopened menu"></p>
<p>Here it is opened:</p>
<p><img src="http://i.stack.imgur.com/gMdZc.png" alt="opened menu"></p>
<p>I found the Menu, which appears in the top right. I don't think they are context menus which you usually see associated with long holding touches.</p>
<p>(I realize these images are from the website, but they are all over honeycomb apps too)</p>
| android | [4] |
450,633 | 450,634 | Another Nesting List comprehension? | <p>In python, suppose I want to turn this list:</p>
<pre><code>['EFJAJCOWSS', 'SDGKSRFDFF', 'ASRJDUSKLK', 'HEANDNDJWA', 'ANSDNCNEOP', 'PMSNFHHEJE', 'JEPQLYNXDL']
</code></pre>
<p>Into:</p>
<pre><code>[['E', 'F', 'J', 'A', 'J', 'C', 'O', 'W', 'S', 'S'], ['S', 'D', 'G', 'K', 'S', 'R', 'F', 'D', 'F', 'F'], ['A', 'S', 'R', 'J', 'D', 'U', 'S', 'K', 'L', 'K'], ['H', 'E', 'A', 'N', 'D', 'N', 'D', 'J', 'W', 'A'], ['A', 'N', 'S', 'D', 'N', 'C', 'N', 'E', 'O', 'P'], ['P', 'M', 'S', 'N', 'F', 'H', 'H', 'E', 'J', 'E'], ['J', 'E', 'P', 'Q', 'L', 'Y', 'N', 'X', 'D', 'L']]
</code></pre>
<p>Thanks</p>
| python | [7] |
2,032,448 | 2,032,449 | str_replace() ignores the count parameter? | <p>As given <a href="http://php.net/manual/en/function.str-replace.php" rel="nofollow">here</a> str_replace() count parameter should stop if certain replacements are done. Right?</p>
<p>Here is my code:</p>
<pre><code>define("PLACEHOLDER", "INSERT INTO `listings` VALUES (NULL, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s');".PHP_EOL);
$r = (4 - count($_POST['ad']));
print count($_POST['ad'])."\n";
print $r;
$pf_args = str_replace("'%s', ", "", PLACEHOLDER, $r);
print $pf_args;
</code></pre>
<p>Now I double-checked everything that <code>$r = 1</code> in one my test and to be doubly sure <code>count($_POST['ad'])</code> is 3. Still, str_replace completely ignores count parameter and replaces all occurances to give:</p>
<pre><code>INSERT INTO `listings` VALUES (NULL, '%s');
</code></pre>
<p>This is driving me insane. Having seen so much <a href="http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-design/" rel="nofollow">anti-php</a> talks, such eccentric behaviour(s) mkes me feel that they are bugs or another one of those weird magic it possesses.</p>
| php | [2] |
4,366,338 | 4,366,339 | jQuery autocomplete change overriding form submit | <p>I have implemented jQuery autocomplete combobox and its working fine. Now I have a wierd issue. Whenever the user types in the combobox and immediately submits the form, the change event in autocomplete is fired which overrides the submit of form. How can i make it work?</p>
| jquery | [5] |
2,226,467 | 2,226,468 | help with if statement | <p>Hey guys im just messing around and I cant get this to work:</p>
<pre><code>public static void main(String[] args){
Scanner input = new Scanner (System.in);
String x = "hey";
System.out.println("What is x?: ");
x = input.nextLine();
System.out.println(x);
if (x == "hello")
System.out.println("hello");
else
System.out.println("goodbye");
}
</code></pre>
<p>it is of course supposed to print hello hello if you enter hello but it will not. I am using Eclipse just to mess around. A little quick help please</p>
| java | [1] |
3,759,732 | 3,759,733 | asp.net web page over vpn | <p>I published a web application to one of app servers. Now, if I am connected within my company network (no login require), I can access the web site no problem. Now, if I am connected from outside of the network over VPN, I can't access the website (Getting page not found appears). Do I need to configure IIS on the app server for allowing the connection over VPN?</p>
<p>Thanks for your time.</p>
| asp.net | [9] |
688,585 | 688,586 | is there any fuction in java which behaves like getopt from c | <p>Hello I am working on command line application which can accepts command line argument like </p>
<pre><code>app -port 8888 -filename d:\xyz\xyz.pdf -dest d:\pqr
</code></pre>
<p>i am looking for fuction which can return me pair of option and it corresponding value like getopt in c.</p>
| java | [1] |
1,809,454 | 1,809,455 | Having one request object as a Method Signature parameter, which constitute all the required parameters | <p>A method signature is part of the method declaration. It is the combination of the method name and the parameter list. </p>
<p>So instead of specifying a list of parameters, I just want to pass a request object which constitute all the parameters. It might not be true for all the methods, but want to try wherever it is possible. </p>
<p>Say for example</p>
<pre><code>public void setMapReference(int xCoordinate, int yCoordinate)
{
//method code
}
</code></pre>
<p>can also be written as</p>
<pre><code>public void setMapReference(Point point)
{
//method code
}
</code></pre>
<hr>
<pre><code>class Point {
int xCoordinate;
int yCoordinate;
boolean isValidPoint();
}
</code></pre>
<hr>
<p>But the caller may confuse as he is not aware of the parameters..!!</p>
<p>Is it a good practice??? </p>
| java | [1] |
3,267,425 | 3,267,426 | take this.id as input and output a changed id for input into a new function | <p>I have a jQuery script that manages a submenu. When the user clicks a div, the div changes to active and then the content changes color accordingly. The buttons have an id tag that is the same as the corresponding div tag, with '_button' added. For example the div to change the color of has id tag 'first', then the buttons id tag is 'first_button'.</p>
<p>The code I have now works fine for the buttons, but I'm not sure how to properly plug in the edited id tag to select the appropriate div to make red with the second jQuery call. Right now the code doesn't do anything to the divs, but I don't receive any errors in the console either. I could do it with a series of if/then statements, but that is rather inelegant.</p>
<pre><code>$('.port_menu_button').click(function() {
$('.port_menu_button').removeClass('active');
$(this).addClass('active');;
$('.port_type').css('color', '#000');
$($(this).attr('id').replace('_button', '')).css('color', 'red'); //this is the problem line. how do I take the id and put it in here?
})
</code></pre>
| jquery | [5] |
2,835,166 | 2,835,167 | jQuery slide vertical images | <p>I hope someone can help me with the following problem.</p>
<p>I have a vertical scrollbar on my website which shows 5 images and will scroll 5 images further or back, depeding on where you clicked.</p>
<p>The jQuery code looks like this.</p>
<pre><code>$(".productSlide .scrollable").scrollable();
$(".productSlide .scrollable").scrollable({ vertical: true, mousewheel: true });
</code></pre>
<p>I am new to jQuery and what I can achieve ist the following</p>
<pre><code><div class="scrollBlock">
<?php
for($i=0; $i<5; $i++)
include 'example1.php';
?>
</div>
<div class="scrollBlock">
<?php
for($i=0; $i<5; $i++)
include ' example1.php';
?>
</div>
<div class="scrollBlock">
<?php
for($i=0; $i<5; $i++)
include ' example1.php';
?>
</div>
</code></pre>
<p>In example1.php there is an image which will be showed 5 times. And everytime you click you’ll see the same div again with the same 5 pics. I can’t figure this one out without the "scrollBlock" div. How can I use more pictures in just one block – and it’s still scrolling 5 images?</p>
<p>Thanks so much!</p>
| jquery | [5] |
5,223,076 | 5,223,077 | how to create a list view in onitemclicklistener of another listview? | <p>I want to create an a <code>ListView</code> item on click listener of another <code>ListView</code>, is it possible to do this?
let me know how to update a existing <code>ListView</code> with new values.</p>
| android | [4] |
841,074 | 841,075 | jQuery Selects Plugin, pull variables from database | <p>I'm using this code to be able to generate an dynamic select:
demo: <a href="http://www.erichynds.com/examples/jquery-related-selects" rel="nofollow">http://www.erichynds.com/examples/jquery-related-selects</a>
code: <a href="https://github.com/ehynds/jquery-related-selects" rel="nofollow">https://github.com/ehynds/jquery-related-selects</a></p>
<p>I have changed the code of the orignal script from:</p>
<pre><code>$counties = array();
$counties['1']['BARN'] = 'Barnstable';
$counties['1']['PLYM'] = 'Plymouth';
$counties['2']['CHIT'] = 'Chittenden';
$counties['3']['ANDE'] = 'Anderson';
</code></pre>
<p>To</p>
<pre><code>$counties = array();
$sql = "SELECT
id,
naam,
klant_id
FROM contactpersoon
ORDER BY klant_id ASC ";
if(!$res = mysql_query($sql,$con))
{
trigger_error(mysql_error().'<br />In query: '.$sql);
}
else
{
while ($row = mysql_fetch_array($res))
{
$counties[$row['klant_id'][$row['id'] = htmlentities($row['naam']);
}
}
</code></pre>
<p>But for some reason the pulldown select list is not created when the changes are made.
When I test the query, no errors shown.</p>
| jquery | [5] |
956,897 | 956,898 | UI Widget drawing in order | <p>I have a custom UI Widget library I've created for a game I'm working on. I need to consider drawing order and retro fit it into what I currently have and not sure of the best way to do so. I have a UI class which loads the widgets from an xml file. It stores all widgets in a map where the key is the string name of the widget.</p>
<p>Widgets can hold other Widgets in a parent child relationship (so the Widget class has a map of Widgets where the name is the key again). When I draw I loop through the UI widget map and only call the Widget's Draw() function's that don't have parents (most top level). Within each Widget's Draw() it loops through it's children and calls their Draw() functions.</p>
<p>The question is what would be a good way to have a sort order variable for each widget work with drawing in the order of the sort order variable while keeping the maps, since I like the ease of finding widgets by the string key name?</p>
<p>Any ideas?</p>
| c++ | [6] |
415,630 | 415,631 | error in installing android sdk starter package | <p>I have downloaded eclipse, the android SDK starter package, and installed the "Developer Tools." Following the guide on developer.android.com exactly. After the developer tools have installed, and eclipse restarts I get two error messages:</p>
<p>1: "SDK Platform Tools component is missing! Please use the SDK Manager to install it."</p>
<p>So, I go in eclipse under Windows > Android SDK Manager and while trying to fetch the files it brings up the sdk manager log with the following:</p>
<pre><code>Fetching https://dl-ssl.google.com/android/repository/addons_list-1.xml
Failed to fetch URL https://dl-ssl.google.com/android/repository/addons_list-1.xml, reason: Invalid argument: connect
Fetched Add-ons List successfully
Fetching URL: https://dl-ssl.google.com/android/repository/repository-5.xml
Failed to fetch URL https://dl-ssl.google.com/android/repository/repository-5.xml, reason: Invalid argument: connect
</code></pre>
<p>Done loading packages.
Can anyone help me in resolving this problem?
Thanking you</p>
| android | [4] |
5,070,773 | 5,070,774 | Recording outgoing call after receiving by the receiver from my Android application? | <p>I want to make a call recording application where user can record his outgoing call. I have done it. But one little problem, call is recording when I am starting to dial a number. I want that , the call will be recorded when the receiver will receive it. Otherwise no sound will be recorded. That means, I want a sound that is free from disgusting dialing tone. Sample code of my application is given below.</p>
<pre><code>//Service
@Override
public void onCallStateChanged(int state, String phonenumber) {
switch (state) {
case TelephonyManager.CALL_STATE_RINGING:
Log.d(TAG, "CALL_STATE_RINGING");
break;
case TelephonyManager.CALL_STATE_OFFHOOK:
Log.d(TAG, "CALL_STATE_OFFHOOK");
isOffHook = true;
try {
Toast.makeText(context, "Recording started", 10000).show();
Toast.makeText(context,
"Recording will stop when call is Diconnected",
10000).show();
startRecord();
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
break;
case TelephonyManager.CALL_STATE_IDLE:
Log.d(TAG, "CALL_STATE_IDLE");
if (isOffHook) {
try {
stopRecord();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
break;
}
</code></pre>
| android | [4] |
1,255,005 | 1,255,006 | How to load class at runtime in android app? | <p>In my android project I've two layouts in that first layout having one button if i click that button I need to display the second layout in the same layout for this I created a view by using <code>LayoutInflater</code> and attached it to "Table Layout" which is present in first layout.</p>
<p>Everything should be fine but the corresponding class file for the second layout is not loading. Without loading I'm not able to call events like click and some other loader events so any one help me how can I load the corresponding class file when i click button in first layout?</p>
| android | [4] |
1,897,937 | 1,897,938 | How to see inbulit classes | <p>I am using android in eclipse . I wanted to see inbuilt classes in android such as 'BaseAdapter' class. Please suggest a method for seeing the content of those classes.</p>
| android | [4] |
4,007,250 | 4,007,251 | Count occurrences of a couple of specific words | <p>I have a list of words, lets say: ["foo", "bar", "baz"] and a large string in which these words may occur. </p>
<p>I now use for every word in the list the "string".count("word") method. This works OK, but seems rather inefficient. For every extra word added to the list the entire string must be iterated over an extra time. </p>
<p>Is their any better method to do this, or should I implement a custom method which iterates over the large string a single time, checking for each character if one of the words in the list has been reached?</p>
<p>To be clear: </p>
<ul>
<li>I want the number of occurrences per word in the list.</li>
<li>The string to search in is different each time and consists of about 10000 chars </li>
<li>The list of words is constant </li>
<li>The words in the list of words can contain whitespace</li>
</ul>
| python | [7] |
5,736,637 | 5,736,638 | reference objects on the stack | <p>Does C# allow you to put reference objects on the stack? Why would you want to do that? What does this mean?</p>
| c# | [0] |
1,456,341 | 1,456,342 | Javascript animation WITHOUT jquery/settimeout/setinterval | <p>As the title says.. is there any possible way to have the simplest of animations in javascript without the use of Jquery, settimeout, and setinterval. I've been researching for too long now and cannot find anything. There may not be a way to do it, just wondering. Looking for something cross browser as well, so CSS animations won't work either.</p>
| javascript | [3] |
100,699 | 100,700 | expand Tiny url in java | <p>I want to write a code in java that takes a url identify whether it is tiny url or not. if yes then it will identify the url is malicious or not. if not malicious print the url...</p>
<p>Please can any body help me....</p>
| java | [1] |
2,369,277 | 2,369,278 | How to attach the source in eclipse using java program? | <p>How can i attach the source in eclipse using java program? Can anyone help me??? Thanks in advance..</p>
| java | [1] |
4,084,933 | 4,084,934 | iphone application icon was blur when show on the itunes store | <p>my icon was blur when show on the itunes Store but fine in iphone's locally appstore,my large icon format is:</p>
<p>pixel:512X512
format:png
dpi:72</p>
<p>can anybody point to me what is the reason of icon getting blur in itunes store since i have followed all the spec required by apple alr</p>
| iphone | [8] |
2,393,595 | 2,393,596 | Inserting values into comboBoxes | <p>I want to use a comboBox in a form that allows users to select the pizza size. I can fill in the comboBox with the strings "small", "Medium", "Large", etc., but I want to associate a price to each string. So a "small" would be $7.99, medium would be 12.99 etc. </p>
<p>So how do I add a value to the string in each item? </p>
<p>Here is what I have so far:</p>
<pre><code>using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace fff
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
comboBox1.Items.Add("Small");
comboBox1.Items.Add("Medium");
comboBox1.Items.Add("Large");
comboBox1.Items.Add("Extra Large");
comboBox2.Items.Add("East End location");
comboBox2.Items.Add("West End location");
comboBox2.Items.Add("South End location");
comboBox2.Items.Add("Downtown location");
comboBox2.Items.Add("North End location");
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void label2_Click(object sender, EventArgs e)
{
}
private void label7_Click(object sender, EventArgs e)
{
}
private void submit_btn_Click(object sender, EventArgs e)
{
if (comboBox1.SelectedIndex == 0)
MessageBox.Show(small);
}
}
}
</code></pre>
| c# | [0] |
423,118 | 423,119 | Suppressing/hiding/overriding Android call UI | <p>Is it possible to initiate an outgoing call without having the phone invoke it's default dialing screen? The point is to be able to make a call without someone knowing I'm making a call.</p>
| android | [4] |
5,569,375 | 5,569,376 | ASP.NET:Get data into Radiobuttonlist from database | <p>I am trying to insert data into radiobuttonlist from the database. but i get this error: Index was out of range. Must be non-negative and less than the size of the collection.</p>
<p>even though i have set the datatype of the field as VARCHAR(MAX). and the data in that field is a simple 4 letter word..say 'john'.</p>
<p>my code for inserting data is like this.:</p>
<p>RadioButtonList1.Items[0].Text = obj.dr["op1"].ToString();</p>
<p>RadioButtonList1.Items[1].Text = obj.dr["op2"].ToString();</p>
<p>RadioButtonList1.Items[2].Text = obj.dr["op3"].ToString();</p>
<p>RadioButtonList1.Items[3].Text = obj.dr["op4"].ToString();</p>
| asp.net | [9] |
3,477,114 | 3,477,115 | PHP Different Environments for Different Users | <p>I've got a PHP application which already has multiple environments setup on different servers (Development, Staging and Production). I'd like to be able to direct different users to different environments based on a database column. We charge users a monthly fee for this application, and we'd like to be able to offer certain users (ones we invite like our mentors) to use our Staging environment so they can help us spot potential problems before they go into production. </p>
<p>What is the best way to handle this? Have a 'environment' column in our users table and redirect the user to the proper environment after they login?</p>
<p>I can't seem to figure out how others have handled this from a good bit of Googling, so any advice would be greatly appreciated.</p>
<p>Thanks.</p>
| php | [2] |
1,156,398 | 1,156,399 | If you use a database to store $_SESSION with session_set_save_handler should you encrypt? | <p>If you use a database to store $_SESSION with session_set_save_handler should yoou encrypt? If you should encrypt any recommendations on what to use to encrypt?</p>
| php | [2] |
2,237,304 | 2,237,305 | android how to show virtual keyboard when pop up a custom dialog | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/2403632/android-show-soft-keyboard-automatically-when-focus-is-on-an-edittext">Android: show soft keyboard automatically when focus is on an EditText</a> </p>
</blockquote>
<p>I want to show the soft keyboard when my dialog pop up to enter the text immediately? (I use android 2.3.3)
I have searched. But all solutions I found not work? Help me!!!</p>
| android | [4] |
80,169 | 80,170 | open the image from a gallery | <p>i m following the helloGallery tutorial but i would like to open the image when i click it instead of present a toast with the position of the image...any help?this is my code,that presents the position:</p>
<pre><code> g.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView parent, View v, int position, long id) {
Toast.makeText(HelloGallery.this, "" + position, Toast.LENGTH_SHORT).show();
}
});
</code></pre>
| android | [4] |
5,401,319 | 5,401,320 | graph drawing using Java | <p>I'm doing graph but I'm stuck; could anyone let me know, How can I draw edge between 2 nodes (I'm using Java) </p>
<p>I have two nodes, but I'm looking for edges between them.</p>
<p>thanks </p>
| java | [1] |
3,737,784 | 3,737,785 | Traditional Practice to initialize the field members of a class | <p>I come from C++ background, where the field of a class are initialized inside the constructor. But here is java I see that I can initialize then while declaring, which is different from C++.</p>
<p>So, I my question was which is the best/traditional practice to initialize the field members of any class. Is it...</p>
<ul>
<li><p>at the time to declaring?</p>
<p>class testClass
{
private int x = 100;
}</p></li>
<li><p>using non-static scope? </p>
<p>class testClass{
private int x;
{
x = 100;
}
}</p></li>
<li><p>or inside of a constructor?</p>
<p>class testClass{
private int x;
testClass(){x = 100;}
}</p></li>
</ul>
<p>( Because I of my background I am a little biased towards initializing field members inside of a constructor.)</p>
| java | [1] |
3,538,683 | 3,538,684 | how would i manage to install python's boto library on shared hosting? | <p>how would i manage to install python's boto library on shared hosting?</p>
| python | [7] |
1,606,583 | 1,606,584 | How to add my custom android application on to the Android software stack? | <p>I have one requirement to add my custom application on to the Android software stack where all core application are added (Home, Calendar,Contacts etc...), so it will always be a part of core application and when user will switch on the device they can find my custom application also available on the home screen.</p>
<p>Now my doubt is how to take the image of android software stack and how to update it with my custom application, if I am able to do it then I can ask device manufacturer to use the updated android software stack. </p>
<p>Can anyone is having any idea regarding this?
any help will be appreciable.</p>
<p>Regards,
Piks.</p>
| android | [4] |
549,883 | 549,884 | Need some jQuery to remove an <a> tag with an empty href | <p>I've tried a couple times but can't seem to figure out how to write a simple piece of jQuery to remove an tag if the href is empty. Here is the string I need to remove.</p>
<pre><code><a id="single_image" href="">Zoom</a>
</code></pre>
<p>Any suggestions? Thanks in advance!</p>
| jquery | [5] |
2,526,036 | 2,526,037 | Reference to Member Variable in Function declaration in C++? | <p>I'm trying to do something like the following:</p>
<pre><code>class FOO {
void bar(int& var = m_var) {
// ....
}
int m_var;
};
</code></pre>
<p>Why doesn't this compile? Why didn't they program this into the language? Is there any way to mimic this behavior?</p>
| c++ | [6] |
3,315,434 | 3,315,435 | is a streaming server necessary to play iPhone streaming video? | <p>I am a noob with regards to this. I just wanted to know if a streaming server is necessary to play streaming videos on the iPhone. </p>
<p>e.g. I have a couple of mp4's hosted on a server. Can i play those files directly using MPMoviePlayerController with the URL <a href="http://xxxx.xx.mp4" rel="nofollow">http://xxxx.xx.mp4</a>?</p>
<p>Are there any commercial solutions for hosting videos for the iPhone?</p>
| iphone | [8] |
1,652,365 | 1,652,366 | Currency format in OpenXML | <p>I am using OpenXML in .net 3.5 to export data table to Excel and want to show specific column as currency.
For example want to show 24.5 as $24.5.Please provide appropriate solution. </p>
<p>Thanks in Advance </p>
| asp.net | [9] |
4,945,571 | 4,945,572 | Is it ok to overwrite the default Math.round javascript functionality? | <p>I have no need to use the Math.round functionality if it does not allow me to choose how many decimal places I want. So I have created the following function that I use instead.</p>
<pre><code>Number.prototype.round = function(precision) {
var numPrecision = (!precision) ? 0 : parseInt(precision, 10);
var roundedNum = Math.round(this * Math.pow(10, numPrecision)) / Math.pow(10, numPrecision);
return roundedNum;
};
</code></pre>
<p>My question is, can I change it to the following instead without any repercussions.</p>
<pre><code>Math.roundP = function(num, precision){
var pow = Math.pow(10, precision||0);
return (Math.round(num*pow) / pow);
};
</code></pre>
<p>I realize that this will overwrite the default Math.round functionality, but I have no need for it. Is this okay in Javascript? I have not done this before so I just wanted to see what peoples thoughts on this is. Or maybe its better for me to leave it the way it is.</p>
<p>I am having trouble deciding when to use Number.prototype, and when to use Math.</p>
| javascript | [3] |
5,756,695 | 5,756,696 | A class with 2 names? | <p>While reading code I came across a class which has 2 identifiers 'naming it':</p>
<pre><code>class A_EXP Node
{
//..
};
</code></pre>
<p>I am not able to understand what this means. Could someone help me out?</p>
| c++ | [6] |
3,821,359 | 3,821,360 | how to throw the value of a variable from loop of one class to another class | <p>i am trying to use the value of a loop of one class into another class
how can i do it.
please help me..</p>
<pre><code> while (!sStreamReader.EndOfStream)
{
string sLine = sStreamReader.ReadLine();
// make sure we have something to work with
if (String.IsNullOrEmpty(sLine)) continue;
string[] cols = sLine.Split(',');
// make sure we have the minimum number of columns to process
if (cols.Length > 4)
{
double a = Convert.ToDouble(cols[1]);
Console.Write(a);
int b = Convert.ToInt32(cols[3]);
Console.WriteLine(b);
Console.WriteLine();
}
}
</code></pre>
<p>i am trying to use the values of a and b into another class.
this loop is another class.</p>
| c# | [0] |
1,380,949 | 1,380,950 | When invoking .NET CLR from within C++, an error is returned | <p>I am calling a .NET assembly from C++. </p>
<p>This works perfectly for any test .NET 4.0 projects that I call. </p>
<p>However, when calling a large project with 20 sub-assemblies, it fails with the error below:</p>
<pre><code>Failed to execute assembly: 0x80004003. GetLastError=126. dwReturn=1.
</code></pre>
<p>Here is the C++ code that generates the error:</p>
<pre><code>DWORD dwReturn;
hr = pCLR->ExecuteInDefaultAppDomain(szApplication, szEntryType, szEntryMethod, szParameter, &dwReturn);
if (FAILED(hr))
{
// Fails if I try the production assembly, with 20 subassemblies.
printf(" Failed to execute assembly: 0x%X. GetLastError=%d. dwReturn=%d.\n", hr, GetLastError(), dwReturn);
}
else
{
// Works 100% if I plug in a small toy assembly in .NET 4.0.
wprintf(L" Assembly returned: %d\n", dwReturn);
}
</code></pre>
<h2>Environment</h2>
<ul>
<li>Visual Studio 2010 SP1.</li>
<li>C++ for the code above.</li>
<li>.NET 4.0 for the target assembly.</li>
</ul>
| c++ | [6] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.