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,310,072
1,310,073
c++ program gets segmentation fault
<p>I've been working on some coding and I ran into a segmentation fault. I've tried my best to make it work but I kept failing. Now I am asking for help. This is my code:</p> <pre><code>#include &lt;iostream&gt; #include &lt;string&gt; using namespace std; int main() { string symbols = "ABCDEFGHIJKLMNOPRSTUVYZ_"; int sim, a = 0; sim = symbols.size(); string temp[sim]; while(sim &gt; 0) { sim--; temp[sim] = symbols.substr(sim, 1); cout &lt;&lt; temp[sim] &lt;&lt; endl; } } </code></pre> <p>Well this kinda works but if I do some changes it crashes.</p> <p>I change:</p> <pre><code> while(sim &gt; 0) { sim--; temp[sim] = symbols.substr(sim, 1); cout &lt;&lt; temp[sim] &lt;&lt; endl; } </code></pre> <p>To this:</p> <pre><code> while(a &lt; sim) { a++; temp[a] = symbols.substr(a, 1); cout &lt;&lt; temp[a] &lt;&lt; endl; } </code></pre> <p>I get SIGFAULT, I don't really understand that is wrong. I used debugger and it doesn't really show at which line it crashes, it just show this:</p> <p>Program received signal SIGSEGV, Segmentation fault.</p> <p>In <code>__gnu_cxx::__exchange_and_add(int volatile *, int) () ()</code></p>
c++
[6]
4,502,699
4,502,700
Is there any problem with this code?
<pre><code>#include&lt;iostream&gt; #include&lt;fstream&gt; #include&lt;cstring&gt; using namespace std; int main() { cout &lt;&lt; "Hello."; ifstream attack,output; attack.open("CattackList"); output.open("finaltestOutput.txt"); if (!attack) cout &lt;&lt; "file1 not opened.\n"; if (!output) cout &lt;&lt; "file2 not opened.\n"; char buf1[100],buf2[100]; attack.getline(buf1,100); int count = 0, C=0; cout &lt;&lt; "hello"; while (!attack.eof()) { C++; cout &lt;&lt; "ok"; output.open("finaltestOutput"); while (!output.eof()) { output.getline(buf2, 80); if (strncmp(buf1, buf2, 51) == 0) { cout &lt;&lt; buf2 &lt;&lt; endl; count++; } } attack.getline(buf1, 80); } cout &lt;&lt; "\nTotal Attacks : " &lt;&lt; C &lt;&lt; endl; cout &lt;&lt; "Attacks detected: " &lt;&lt; count &lt;&lt; endl; return 0; } </code></pre> <p>I am not able to get even the first "Hello" to get printed...</p>
c++
[6]
466,904
466,905
Built-in date time picker control in Android that looks like the datetime picker of the Calendar Application
<p>Is the control shown in the image below built-in in the Android Framework or it is a custom control. If it is custom control, should it be built using a button with background that pops a calendar dialog on click?</p> <p><img src="http://i.stack.imgur.com/j3UGs.jpg" alt="snapshot"></p> <p>Thanks</p>
android
[4]
801,139
801,140
Can you use a function local class as predicate to find_if?
<p>Is it possible to use a local class as a predicate to std::find_if?</p> <pre><code>#include &lt;algorithm&gt; struct Cont { char* foo() { struct Query { Query(unsigned column) : m_column(column) {} bool operator()(char c) { return ...; } unsigned m_column; }; char str[] = "MY LONG LONG LONG LONG LONG SEARCH STRING"; return std::find_if(str, str+45, Query(1)); } }; int main() { Cont c; c.foo(); return 0; } </code></pre> <p>I get the following compiler error on gcc:</p> <pre><code>error: no matching function for call to 'find_if(char [52], char*, Cont::foo()::Query)' </code></pre> <p><strong>EDIT: Changing nested to local</strong></p>
c++
[6]
5,634,001
5,634,002
onCreateDialog doesn't refresh message
<p>I try to create AlertDialog. It works but setMessage doesn't refresh message. Code snippet below: </p> <pre><code>@Override protected Dialog onCreateDialog(int id) { super.onCreateDialog(id); switch (id) { case CONFIRM: confirmView = new LinearLayout(this); return new AlertDialog.Builder(this) .setIcon(android.R.drawable.ic_dialog_info) .setView(confirmView) .setCancelable(false) .setTitle("The WiFi") .setMessage(infoMsg); .setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { Functionality.StartWiFiManager(ControllerService.this); } }) .setNegativeButton("Cancel", new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }) .create(); } } </code></pre> <p>Invoking:</p> <pre><code>infoMsg = "My message"; showDialog(CONFIRM); </code></pre> <p>So when I change my infoMsg and invoke showDialog again, the message is the same. What am I doing wrong? Please, help me.</p>
android
[4]
3,338,702
3,338,703
Animating Activity on onStartActivity
<p>I want to animate an activity while starting another activity. The animation i am trying to do flip animation.</p> <p>I tried ActivityOptions and overridePendingTransition with objectanimtor. I think i am doing wrong ,objectanimator can not be used with these above methods.</p> <p>Is there any way to animate activity that work for api level 8 also, please also explain the reason why objecanimator not working with ActivityOptions and overridePendingTransition </p> <p>Below the sample is attached</p> <pre><code> &lt;set xmlns:android="http://schemas.android.com/apk/res/android"&gt; &lt;!-- Before rotating, immediately set the alpha to 0. --&gt; &lt;objectAnimator android:valueFrom="1.0" android:valueTo="0.0" android:propertyName="alpha" android:duration="0" /&gt; &lt;!-- Rotate. --&gt; &lt;objectAnimator android:valueFrom="180" android:valueTo="0" android:propertyName="rotationY" android:interpolator="@android:interpolator/accelerate_decelerate" android:duration="@integer/card_flip_time_full" /&gt; &lt;!-- Half-way through the rotation (see startOffset), set the alpha to 1. --&gt; &lt;`objectAnimator` android:valueFrom="0.0" android:valueTo="1.0" android:propertyName="alpha" android:startOffset="@integer/card_flip_time_half" android:duration="1" /&gt; &lt;/set&gt; `enter code here`and i used this `xml` like this `overridePendingTransition`(`R.anim.card`_flip_right_in,`R.anim.card`_flip_right_out); </code></pre>
android
[4]
1,497,838
1,497,839
What's the best way to display a bunch of images from a web server in Android?
<p>I need to load several thumbnails (the images on the server are full sized images, so I need to resize them in the app), and display them in a way that allows for the user to click on one (or more) and have some associated id be given back to the app for use in a larger context. </p> <p>so, in pseudo code...</p> <pre><code>ImageObjArray ioa = loadImagesFromServer("http://server/listOfImages.php");// this returns for(ImageObj io : ioa){ drawThumbnail(io); //io contains both a jpg and a reference id } //later when a user clicks on a thumbnail clickHandler(){ passIdToBundle(this.refId); } </code></pre> <p>So, I've never played with a webview before but I suspect it might be the best approach here, though I don't know how easy it is to send info back out of a webview to the larger app when the user clicks on a thumbnail. Or is there a more elegant approach?</p> <p>All advice welcome. </p>
android
[4]
4,235,969
4,235,970
Java Software Engineering
<p>I'm a newbie to software engineering. People around me used to talk some jargons such as dto, bo,do ,so and so on. What all those means. Is there are any books to refer about those. i 'm into java software development.</p>
java
[1]
3,448,132
3,448,133
Function that takes an STL iterator over ANY container of a elements of a specific type
<p>How would I define a function that takes as input an iterator over any type of STL container, but only to those of a specific templated type. For example:</p> <p>Any iterator of the form <code>std::list&lt;Unit*&gt;::iterator</code> <strong>or</strong> <code>std::vector&lt;Unit*&gt;::iterator</code></p> <p>I would just define the function to take <code>std::list&lt;Unit*&gt;::iterator</code>, but if we switch to a different STL container, I don't want to have to change my code.</p> <p>Is there a way to do this with templates or otherwise?</p>
c++
[6]
477,181
477,182
how to write the condition?
<pre><code>$tree = taxonomy_get_tree($vid); print "&lt;li&gt;"; // 1 line foreach ($tree as $term ) { // 2 lines $diffdepth=0; if ($term-&gt;depth &gt; $depth) { print "&lt;ul class='haschild'&gt;&lt;li&gt;"; $depth = $term-&gt;depth; } </code></pre> <p>the above is the original code, now I want according to <code>$term-&gt;depth &gt; $depth</code> make a condition to output.( <code>print "&lt;li&gt;";</code> ) this line.</p> <p>namely, </p> <pre><code>if ($term-&gt;depth &gt; $depth) { echo '&lt;li class="parent"&gt;'; } else { print "&lt;li&gt;"; } </code></pre> <p>but <code>$term-&gt;depth</code> can use after foreach loop, but i want to use it at 1 line, how do i do?</p>
php
[2]
174,525
174,526
Jquery display images one after another
<p>This is perhaps a couple of questions rolled into one here, I am creating an image gallery and wanted the thumbnails to fade in on the page one after another, this needs to be dynamic to the amount of images within a div (for reuse on the other gallery pages)</p> <pre><code>$(function { var $gallImages = $('#galleryThumbs img'); for(i=0; i&lt;=$gallImages.length; i++){ $(document.getElementById('galleryThumbs').getElementsByTagName('img')[i]).addClass('done').fadeIn('slow'); }}); </code></pre> <p>This displays the images all at the same time on load:(</p> <p>Also is there a better way to do element collection in jQuery I couldn't find anything about using the array needed for the image tags</p> <p>Any help on this would be appreciated, am hitting a mental block on this</p>
jquery
[5]
512,373
512,374
bind causing errors
<p>I'm noticing some errors that are occurring because of JQuery bind. What happens is that when I submit a form, bind causes a javascript error to occur when the page that uses it is not loaded. When I comment the bind section out, the error goes away.</p> <p>Here are the relevant lines of code.</p> <pre><code> $('input').bind('click', function() { editor.post(); }); $("#submit").click(function () { ... </code></pre> <p>Is there a way to move the bind click function inside of the submit click function? If not, how can I stop this error from occurring?</p> <hr> <p>This is the error:</p> <pre><code>editor is not defined script.js editor.post(); </code></pre>
jquery
[5]
1,396,809
1,396,810
Pushing Array value to first Index
<pre><code>var Config = { Windows: ['apple','mangi','lemon'] } </code></pre> <p>I have a condition and based on that i want to Push the banana value in my Array. </p> <pre><code>If(Condition Passed) { Config.Windows.unshift('banana'); Windows: ['banana','apple','mangi','lemon'] Config.Windows.reverse(); // The way the Array elements are now reversed and First banana is accessed. } else { Config.Windows.reverse(); } </code></pre> <p>It does not do it... when i use the Config.Windows in my other function there is no <code>banana</code> Value... at all</p> <pre><code>for each(var item in Config.Windows.reverse()) { Ti.API.info(item); //This does not print banana </code></pre>
javascript
[3]
5,621,116
5,621,117
Android add more smileys in one edittext?
<p>I need to add more than one smileys in a single edittext box. For add a single smiley I follow <a href="http://www.iteedu.com/handset/android/spannablediary/imagespan.php" rel="nofollow">this link</a></p> <p>How to add more smileys in a single Edittext box? Thanks in advance..</p>
android
[4]
1,358,480
1,358,481
Android external keyboard ctrl keycode
<p>I want to listen if the <code>ctrl key</code> is pressed but in <code>android 2.3</code> ,there is no <code>ctrl's keycode</code>.</p> <p>My device cannot update to <code>android 3.0</code></p> <p>Are there any ways to solve this problem?</p>
android
[4]
4,852,618
4,852,619
Phantom uindentation: unexpected unindent on blank line
<p>I'm getting the following indentation error with a completely nonexistent line (the code ends at line 17, there is no line 18 on the page):</p> <pre><code> File "./test.py", line 18 ^ IndentationError: unexpected unindent </code></pre> <p>I've tried resaving the file as new, everything. What's going on??</p>
python
[7]
163,219
163,220
Why does MonkeyRunner.waitForConnection() error "Adb rejected adb port forwarding command: cannot bind socket"
<p>When I try to get a device with MonkeyRunner I get this message:</p> <blockquote> <blockquote> <blockquote> <p>newdevice = MonkeyRunner.waitForConnection() 110804 17:35:28.561:S [main] [com.android.monkeyrunner.adb.AdbMonkeyDevice] Adb rejected adb port forwarding command: cannot bind socket 110804 17:35:28.561:S [main] [com.android.monkeyrunner.adb.AdbMonkeyDevice]com.android.ddmlib.AdbCommandRejectedException: cannot bind socket</p> </blockquote> </blockquote> </blockquote> <p>I'm running monkeyrunner.bat from the commandline in windows Xp with JDK 1.6.0_26, Python 2.7.2, and Android SDK 11. adb devices shows my USB device.</p>
android
[4]
1,200,960
1,200,961
handling javascript object existence checks globally
<p>My JS developers always miss checking the object existence causing doucument.getElementByID is null problem. is there a way to handle this globally than adding the check for every single object. or is it possible to handle/suppress it during runtime?</p>
javascript
[3]
959,193
959,194
How to open Maps app from my code to show directions?
<p>HI.. I have to show directions between two coordinates. I'd like to open Maps app, passing the start and end coordinates from my code. </p> <p>I don't want to open it in the Google maps, which opens in browser(Safari). I tried that method. That was working perfect.</p> <pre><code>NSString* urlStr = [NSString stringWithFormat: @"http://maps.google.com/maps?saddr=%f,%f&amp;daddr=%f,%f", s_lat, s_long, d_lat, d_long]; [[UIApplication sharedApplication] openURL: [NSURL URLWithString:urlStr]]; </code></pre> <p>But, I want to open iPhone Maps app. How can i do this? Is this possible? Any help will be appreciated.</p>
iphone
[8]
3,549,744
3,549,745
polymorphisim java
<p>I'm getting the fine after computing the method <code>computeFine()</code> it returns the result <code>0</code> each time I put any <code>period</code></p> <p>Please check it here because it is very long and it's hard to past it in SOF</p> <p><a href="http://paste.org/pastebin/view/40017" rel="nofollow">http://paste.org/pastebin/view/40017</a></p>
java
[1]
49,176
49,177
I want to use google map API with PHP but unsure how
<p>I currently have a webpage where people can see their local bus routes and when they click on their route it loads a page with a google map through their API with what stops it stops at and times it arrives. But I'm currently using a lot of get statements e.g. '?route.php=blahroute1' which will tell the loading page which to load, but how can I change the JavaScript (in its own file) to load the propper map on route.php. Sorry for poor indentation and formatting, on my phone. </p>
php
[2]
716,915
716,916
Switching font for android app
<p>I have downloaded multiple fonts and would like to apply them throughout my app. Can this be done? I tried searching on stack overflow and could not find anyone that fits my request. Please help me.</p> <p>thanks.</p>
android
[4]
1,420,956
1,420,957
Change background image of listview on item selected from adapter
<p>In my getView method from my listadapter, When i select an item in the list, i want this selected item background image to take a specific image and the other items from the list to take the default background image. I implemented a for loop to do this but when i select an item from the row, the background image doesn't change.. can we change background image from a button click ? and where am i wrong because i believe my code is ok. Here is the part where the selected item is checked.</p> <p>pos = position;</p> <pre><code> size = main.items.size()-1; holder.row.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { int x = position + 1; for (int i=0;i&lt;size;i++){ holder.row.setBackgroundResource(R.drawable.layer_unselected); holder.text.setTextColor(Color.WHITE); if (x==main.items.size()-1){ holder.row.setBackgroundResource(R.drawable.layer_selected); holder.text.setTextColor(Color.BLACK); } } System.out.println("selected layer: "+ x ); System.out.println("selected layer pos: "+pos); System.out.println("selected layer size: "+size); main.selectItem(position+1); } }); </code></pre>
android
[4]
1,008,439
1,008,440
Custom event handler not getting initialized
<p>Following is the Code i am using </p> <pre><code>class ImpersonatedTab : System.Windows.Forms.TabPage { Credentials _cred = new Credentials(); public delegate void Savesetting(TabData Tb); public event Savesetting TriggerSaveSetting; public ImpersonatedTab(TabData tb) { ........ } private void SaveData() { TriggerSaveSetting(_tabdata); } private Onclick() { SaveData(); } } </code></pre> <p>When i call Onclick function within ImpersonatedTab class it returns error saying TriggerSaveSetting is null</p> <p>I initialize this call like </p> <pre><code>ImpersonatedTab Tab = new ImpersonatedTab(tb); Tab.TriggerSaveSetting += new ImpersonatedTab.Savesetting(Tab_TriggerSaveSetting); </code></pre> <p>i have created events earlier, but am not able to figure out whats wrong with this one.. i am sure should be some silly mistake.</p>
c#
[0]
3,984,747
3,984,748
Having problems with storing variable in classes
<p>Please see ifmy logic is correct i do not know how to implement what i am trying to do. I am a beginner in java.</p> <p>Game is a class which stores the Name and the Steps of that user after the game is complete.</p> <p>[ First Method ]</p> <pre><code>private game[] gameArray = new game[10]; for(int i = 0; i &lt;gameArray.length;i++){ gameArray[i].setName(nameTxt.getText()); gameArray[i].setpSteps(stepsCount); } </code></pre> <p>By Clicking History Button they will get the previous 10 people's name and steps.</p> <pre><code>JOptionPane.showMessageDialog(null, "Player's Name No. of Steps"+ "\n"+gameArray[i].toString()); </code></pre> <p>-The Problem:</p> <p>1) This code limits to only previous 10 results is there anyway i can get all the previous results</p> <p>2) This code is not working!</p> <p>[ Second Method - This is also not working! ]</p> <pre><code>private game[] gameArray = new game[10]; // Storing the name of player[i] gameArray[i].setName(nameTxt.getName()); // Storing the number of steps player[i] took. gameArray[i].setpSteps(stepsCount); //Displaying previous 10 players name and steps JOptionPane.showMessageDialog(null, "Player's Name No. of Steps"+ "\n"+gameArray[i].toString()); </code></pre>
java
[1]
3,516,132
3,516,133
How to put variables into calling scope in PHP?
<p>The built-in PHP function parse_str( $str ) parses a query string and sets the variables from it into the current scope. Is there any way for me to create my own function that does something like this and returns values to the scope of the caller?</p> <p>Example:</p> <pre><code>function checkset() { global $inputs; for( $counter = 0, $varname = func_get_arg($counter), $counter++) { if(isset($inputs[$varname])) { calling_scope( $varname, $inputs[$varname] ); } } return; } </code></pre> <p>where calling_scope( $varname, $value) would be a function that sets $$varname in the scope where the function is called to $value. Any help is appreciated.</p>
php
[2]
202,800
202,801
Can I turn off power save function of emulator?
<p>Whenever I execute my app, I have to click one more time to brighten emulator screen. Is there any way I can turn off power save function of emulator?</p>
android
[4]
3,339,819
3,339,820
Creating an accurate Bible Search
<p>I am creating a Bible search. The trouble with bible searches is that people often enter different kinds of searches, and I need to split them up accordingly. So i figured the best way to start out would be to remove all spaces, and work through the string there. Different types of searches could be:</p> <p><code>Genesis 1:1</code> - Genesis Chapter 1, Verse 1</p> <p><code>1 Kings 2:5</code> - 1 Kings Chapter 2, Verse 5</p> <p><code>Job 3</code> - Job Chapter 3</p> <p><code>Romans 8:1-7</code> - Romans Chapter 8 Verses 1 to 7</p> <p><code>1 John 5:6-11</code> - 1 John Chapter 5 Verses 6 - 11.</p> <p>I am not too phased by the different types of searches, But If anyone can find a simpler way to do this or know's of a great way to do this then please tell me how!</p> <p>Thanks</p>
php
[2]
3,640,567
3,640,568
cin condition checking error
<p>I am a beginner programmer learning c++. I am having a nagging issue with the cin command. In the program section below, if I enter a wrong type at the 1st cin command, the program will not execute any of the following cin commands at all, but will execute the rest of the program. </p> <pre><code>//start #include &lt;iostream&gt; using namespace std; int main() { int x=0; cout &lt;&lt; endl &lt;&lt; "Enter an integer" &lt;&lt; endl; //enter integer here. If wrong type is entered, goes to else if (cin &gt;&gt; x){ cout &lt;&lt; "The value is " &lt;&lt; x &lt;&lt; endl; } else { cout &lt;&lt; "You made a mistake" &lt;&lt; endl; //executes cin.ignore(); cin.clear(); } cout &lt;&lt; "Check 1" &lt;&lt; endl; //executes cin &gt;&gt; x; //skips cout &lt;&lt; "Check 2" &lt;&lt; endl; //executes cin &gt;&gt; x; //skips return 0; } //end </code></pre> <p>Instead of the if else, if i put the same concept in a loop while (!(cin >> x)) the program goes into an infinite loop upon enterring a wrong input. Please help me explain this phenomenon, as the text book i am following says the code typed above should work as intended.</p> <p>Thank you</p>
c++
[6]
484,384
484,385
Python, simple FTP upload .txt
<p>I'm really struggling just to get a simple <code>.txt</code> file to upload to a FTP server. I've got a folder on my desktop which contains two files: <code>text.txt</code> and <code>upload_to_ftp.py</code>.</p> <p>I've tried these:<br> <a href="http://love-python.blogspot.com.au/2008/02/ftp-file-upload.html" rel="nofollow">FTP file upload</a><br> <a href="http://stackoverflow.com/questions/12613797/python-script-uploading-files-via-ftp">Python Script Uploading files via FTP</a><br> But neither seem to work.</p> <p>I've re-written the code so many times its doing my head in and i keep getting errors such as:</p> <pre><code>sftp = ftplib.FTP('REMOTEFTPSITE.com', 'MYUSERNAME', 'MYPASSWORD') File "C:\Python27\lib\ftplib.py", line 117, in __init__ self.connect(host) File "C:\Python27\lib\ftplib.py", line 135, in connect self.welcome = self.getresp() File "C:\Python27\lib\ftplib.py", line 210, in getresp resp = self.getmultiline() File "C:\Python27\lib\ftplib.py", line 196, in getmultiline line = self.getline() File "C:\Python27\lib\ftplib.py", line 183, in getline line = self.file.readline() File "C:\Python27\lib\socket.py", line 447, in readline data = self._sock.recv(self._rbufsize) error: [Errno 10054] An existing connection was forcibly closed by the remote host </code></pre> <p>Any help would be great! Thanks in advance.</p>
python
[7]
3,380,215
3,380,216
Paint bitmap on Canvas ignoring alpha channel
<p>I have a Bitmap with an alpha channel (ARGB8888), and I just want to paint it ignoring the alpha bytes. Modifying the alpha channel is not an option.</p> <p>Is there a way of doing this? Thanks!</p>
android
[4]
3,599,246
3,599,247
ProgresDialog doesn't show up
<pre><code>public Context ctx; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.ctx = this; //another code......) send = (Button)findViewById(R.id.wyslij_zapytanie_ofertowe); send.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub ProgressDialog dialog = ProgressDialog.show(ctx, "Loading", "Please wait...", true); try { GMailSender sender = new GMailSender("dasdda@gmail.com", "ddx"); sender.sendMail("This is Subject", "This is Body", "staxxxowe@gmail.com", "xxxyk@gmail.com"); dialog.dismiss(); } catch (Exception e) { Log.e("SendMail", e.getMessage(), e); dialog.dismiss(); } } }); </code></pre> <p>I try also instead ctx put ClassName.class and also doesn't work. Any one have idea how to solve this problem?</p>
android
[4]
4,400,718
4,400,719
Jquery .next() function not working
<p>Guys i am trying to do something like this i have two href and a text box in the middle of those &lt;-> TEXT &lt;+> So when i press the - and + the value in the txt must increase or decrease by one</p> <p>and i am using a jquery to + and - the value in the text box. Whenever i press + its happening correctly but for - it takes the TEXT fields name instead of its value . Any solution for this to make it to take the value of the TEXT box Jquery used follows :</p> <pre><code>$(".quantity .subtract").click(function () { var qtyInput = $(this).next('input'); var qty = parseInt(qtyInput.val()); if (qty &gt; 1) qtyInput.val(qty - 1); qtyInput.focus(); return false; }); $(".quantity .add").click(function () { var qtyInput = $(this).prev('input'); var qty = parseInt(qtyInput.val()); if (qty &gt;= 0 &amp;&amp; (qty + 1 &lt;= 999)) qtyInput.val(qty + 1); qtyInput.focus(); return false; }); </code></pre> <p>And their Ids ll be different as more than one time i m using thm in the page</p>
jquery
[5]
1,036,934
1,036,935
Shuffling a Deck of Cards , Redundancy after swapping two values
<p>I was asked to write a program(mainly a method) for shuffling a deck of cards. I wrote the following program:</p> <pre><code>public class Deck { //////////////////////////////////////// // Data Members //////////////////////////////////////// private Card[] cards; // array holding all 52 cards private int cardsInDeck; // the current number of cards in the deck public static final int DECK_SIZE = 52; /** * Shuffles the deck (i.e. randomly reorders the cards in the deck). */ public void shuffle() { int newI; Card temp; Random randIndex = new Random(); for (int i = 0; i &lt; cardsInDeck; i++) { // pick a random index between 0 and cardsInDeck - 1 newI = randIndex.nextInt(cardsInDeck); // swap cards[i] and cards[newI] temp = cards[i]; cards[i] = cards[newI]; cards[newI] = temp; } } } </code></pre> <p>But there is a logical error in the above shuffle method which is as follows: Suppose I replace Card Number 4 with Card Number 42, then I'm swapping two times. I'm wondering is there any way of not doing this?</p> <p>I checked one post here :<a href="http://stackoverflow.com/questions/4075439/shuffling-a-deck-of-cards">Shuffling a deck of cards</a></p> <p>But it didn't make sense to me.</p>
java
[1]
5,947,076
5,947,077
android media player is not playing audio file from url which has space or special character
<p>i am trying to make media player for audio file.</p> <p>when i play a file which has space or special character like this </p> <pre><code>[str=**http://192.168.1.214/MusicApplication/Songs/Baek Chan &amp; Joo Hee of 8eight.mp3**;] </code></pre> <p>using </p> <pre><code> mediaPlayer=new MediaPlayer(); mediaPlayer.setDataSource(str); mediaPlayer.prepare(); </code></pre> <p>media player does not play file. </p> <p>if i use this type of <code>url:- str=**http://192.168.1.214/MusicApplication/Songs/Baek.mp3**;</code></p> <p>it works properly. please tell me what should i do to solve this type of problem.</p> <p>Thank you in advance.</p>
android
[4]
532,043
532,044
Why do these two 'x' refer to different variable?
<p>In this code, the x in the lambda refers to the x in the for statement. So <code>y[0]()</code> returns 2:</p> <pre><code>x = 0 y = [lambda : x for x in range(3)] y[0]() </code></pre> <p>But in this code, the x in the lambda refers to global x, so <code>x[0]()</code> returns global x itself:<br /></p> <pre><code>x = [lambda : x for x in range(3)] x[0]() </code></pre> <p>I want to know why the x in the lambda refers to the local x in the first piece of code but global x in the second piece of code.</p>
python
[7]
952,984
952,985
Pass long[] instead of Long
<p>I have a function like this</p> <pre><code>void doSmth(Long... paramg){ } </code></pre> <p>But I can't pass <code>long[]</code> instead of <code>Long...</code>. Why? I thought it's the same things (whats the difference between them?).</p> <p><strong>How can I pass long[] instead of Long... ?</strong></p>
java
[1]
3,533,095
3,533,096
what is android support library
<p>what is the purpose of Android Support Library? Does this mean </p> <pre><code> http://developer.android.com/tools/extras/support-library.html </code></pre> <p>Currently my app has min sdk restriction of level 10 I am trying to use ViewPager, which is not available at higher api (level 16 I believe)</p> <p>So what does this support library mean? Does it mean I can use ViewPager and user of the phone with api level less than 16 can still see ViewPager widget?</p> <p>Please help</p>
android
[4]
4,735,216
4,735,217
Send data from phone to phone over internet?
<p>Is there any way to actually communicate between two android devices over internet without having to have any service between the two devices? </p> <p>Like posting something to device2 from device1 without having to "middle-land" on any other server or whatever?</p> <p>Another question: I tried to ping my phone over the internet (simply using the IP address), which didn't work, since it seems like my ISP shares the same WAN-IP for all the phones or at least a few of them. So is there any way to actually ping or send data to my specific phone just by using the IP or my Google account or something?</p>
android
[4]
1,656,490
1,656,491
ACTION Cannot be resolved - Android SMS Programming
<p>I am following a tutorial regarding a certain SMS Android program, specifically SMS Parsing. </p> <p>I had this particular error that i meet...</p> <pre><code> Public class SMSTestActivity extends BroadcastReceiver { public void onReceive (Context context, Intent intent) { if (intent.getAction().equals(ACTION)) { Bundle bundle = intent.getExtras(); if (bundle != null) { Object[] pdusObj = (Object[]) bundle.get("pdus"); SmsMessage[] messages = new SmsMessage[pdusObj.length]; </code></pre> <p>How could I fix this?</p>
android
[4]
5,720,853
5,720,854
How do i pass an value to a function that i use as parameter?
<p>i want to pass a function as an parameter if an element was clicked. But in the function that i pass i want to set an attribute information from the clicked element.</p> <p>What is the best way to pass the attribute value to the inner of the function?</p> <p>My JavaScript looks like this:</p> <pre><code>$('.edit-link').livequery(function(){ $('.edit-link').click(function(){ WMT.openOverlay($('#edit'),{ relativeTo: $('.search'), width: $('.search'), close: $('#cancel_edit'), fillFields: function(){ return $.getJSON("ajax/edit.php?id=" + $(clickedElement).data('id')); } }); }); }); </code></pre> <p>i want to send the data attribute "id" in the json.</p>
javascript
[3]
4,274,808
4,274,809
Can nflx:// app run within an IOS app using UIWebView
<p>I am writing an IOS app where I would like to launch the Netflix app (nflx://) within my app using UIWebView. I would like to have the Netfix movies run within my UIWebview structure so when the user stops the movie it will go back to my app control.</p> <p>I have have done the following:</p> <p>1). I can launch nflx:// within UIWebview and the app immediately launches by leaving my app.</p> <pre><code>NSURL *url = [NSURL URLWithString:@"nflx://"]; NSURLRequest *requestPage = [NSURLRequest requestWithURL: url]; loadingView = [LoadingView loadingViewInView:webPage]; self.webPage.delegate = self; [self.webPage loadRequest: requestPage]; [self.webPage setScalesPageToFit:YES]; </code></pre> <p>2). I have launched the Netflix website @"movies.netflix.com://. This allows the user to select the video within my app, but once the video starts it exits to the Netflix app. </p> <pre><code>NSURL *url = [NSURL URLWithString:@"@"movies.netflix.com://"]; NSURLRequest *requestPage = [NSURLRequest requestWithURL: url]; loadingView = [LoadingView loadingViewInView:webPage]; self.webPage.delegate = self; [self.webPage loadRequest: requestPage]; [self.webPage setScalesPageToFit:YES]; </code></pre> <p>Is this possible? If so any guidance would be helpful.</p> <p>Thanks</p>
iphone
[8]
1,893,622
1,893,623
How to convert intptr_t to string
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/5590381/easiest-way-to-convert-int-to-string-in-c">Easiest way to convert int to string in C++</a> </p> </blockquote> <p>Does anyone know how to do that conversion?</p> <p>I need to concatenate a intptr_t type to a string, and therefore need to convert it.</p> <p>It's not an int, as It's a 64 bit OS.</p> <p>Correct me if I'm wrong Thanks</p>
c++
[6]
5,927,614
5,927,615
Passing SESSION variables
<p>Let's say I have a questionnaire consisting of three pages that a user is supposed to submit. I collect variables through SESSION. Should I pass all the variables in session from page to page repeating them or could I pass variables from page one to page three? For example, I have 'first name' and 'last name' on page 1, 'email' and 'address' on page 2, 'age' and 'occupation' on page 3. Could I pass 'first name' and 'last name' from page 1 directly to page 3? Or I will have to pass them to page 2 first and then pass them again from page 2 to page 3?</p> <p>Thank you!</p>
php
[2]
50,094
50,095
what is the best Serializable replacement for "Set" and "Collection" interfaces?
<p>I have to serialize Collection and Set interfaces. Which are the best Serializable replacements for those interfaces on Java?</p>
java
[1]
2,895,754
2,895,755
Mouseout Call Event
<p>I wanted to use <a href="http://james.padolsey.com/javascript/table-rows-as-clickable-anchors/" rel="nofollow">this plugin</a> for hover effects on a table row but retaining the links correctly in the browser. The problem is that against the latest version of jQuery there is a section of the plugin that doesn't work, namely a method called <code>call</code>.</p> <p>Here's a useful snippet:</p> <pre><code> var mouseouts = $(this).data('events') &amp;&amp; $(this).data('events').mouseout; if (mouseouts) { $.each(mouseouts, function (i, fn) { $targetLink.mouseout(function (e) { fn.call($container, e); }); }); delete $(this).data('events').mouseout; } </code></pre> <p><code>fn.call</code> fails, but I can't seem to find when this was deprecated, or what its replacement is.</p> <p>Any clues?</p>
jquery
[5]
3,327,969
3,327,970
How do I detect focus on an InputText field in Android?
<p>I know I MUST be a total idiot, but I don't see anything in the documentation that resembles an onFocus event handler for an InputText view in Android.</p> <p>What am I overlooking?</p>
android
[4]
601,412
601,413
List all NAS server present in LAN using C#
<p>I want to List all NAS server present in LAN using C#. Any idea or code snippet is highly appreciated. Thanks in Advance.</p>
c#
[0]
5,325,507
5,325,508
How much time do you spend in JavaScript development ? And what do you do to reduce it?
<p>I would like to know how much time (in percent) does JavaScript development takes at your work. I work with complex rich-internet applications and i spend most of my time in JavaScript development. </p> <p>And you: how much time do you you spend in JavaScript development and what do you do to reduce it ?</p> <p>regards,</p>
javascript
[3]
5,516,676
5,516,677
Use jQuery prepend to add div element
<p>I wonder if it's possible to have several div elements with different id that has different contents and then add them with prepend depending of the choice from a menu? When the page load, all of these element should be hidden. Could I do that? </p> <p>EDIT: Instead of load several different pages with just some text, but with different subject, my idea was to have all info on one page and just show the some parts depending on the user choice. Is this a bad idea?</p>
jquery
[5]
5,397,197
5,397,198
Can python be integrated into HTML, JavaScript... Online?
<p>I have a python multiplayer game which I want to host online. So far I have only seen online games which use some kind of user downloaded library (such as a flash or the java runtime virtual box) of course, many gamers won't have python installed. For the game, it is using the multiplayer by the library socket, and the tcp protocol. I hope someone has some framework, or even just some links thats could help.</p> <p>Thanks</p>
python
[7]
4,510,651
4,510,652
Carousel library for android
<p>Is there any library available for Carousel animation of images as available in iphone <a href="http://cocoacontrols.com/platforms/ios/controls/icarousel" rel="nofollow">http://cocoacontrols.com/platforms/ios/controls/icarousel</a></p> <p>I have used cover flow but it is not giving effect like iCarousel in iphone,so If some other tricks by which i can implement this please give me Thanks</p>
android
[4]
5,924,385
5,924,386
javascript: || (or) in variable define?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/2802055/what-does-this-construct-x-x-y-mean">What does this construct (x = x || y) mean?</a> </p> </blockquote> <p>a lot of times i can see that variables set like that </p> <pre><code>var d = d || {} </code></pre> <p>or</p> <pre><code>var = var || [] </code></pre> <p>a few question came up to mind</p> <ol> <li>what it's mainly purpose ?</li> <li>how can it be to use OR in variable define?</li> </ol>
javascript
[3]
1,893,826
1,893,827
Image Preloading for image gallery
<p>suppose i am showing images through datalist control. datalist have 5 rows and 5 columns. all rows and all columns will show a small image. so when i am showing images then it is taking little time. so i want to show a image pre-loader for each image. so at the very beginning when page will be running then many busy indicator will show for each image and when each image will show in the page gradually then image preloader for that image will be invisible. so please guide me how to develop my image gallery in this way.</p> <p>example site is <a href="http://davidwalsh.name/dw-content/lazyload-fade.php" rel="nofollow">http://davidwalsh.name/dw-content/lazyload-fade.php</a></p> <p>i want the output like above url.</p> <p>thanks</p>
asp.net
[9]
4,154,860
4,154,861
If i don't have a website's database, what is the alternative to retrieve its informations in Android app?
<p>I want to develop an app to display the programs schedule of a specific channel from its website. I don't have their website indeed, however, is there some other techniques to retrieve some specific data from a page, in my case the name of the program and its diffusion time. The website does not have an RSS feed too. Any ideas please? Thank you very much.</p>
android
[4]
5,894,813
5,894,814
How do I get number of common numbers in an array record in Mysql?
<p>How do I get mode of an array record in Mysql? <br>i.e: 1,2,3,4,5 , 1,3,5<br> I would like to get out of the table user_friends to get which friends these friends have in common, in this case, 1,3,5. How would I accomplish this?</p>
php
[2]
4,321,448
4,321,449
Javascript Delete Method?
<p>In this code snippet from AdvancED DOM Scripting:</p> <p>The call to <code>delete(classes[i]);</code> is this an array or object method? I'm unable to Google an answer.</p> <pre><code>/** * remove a class from an element */ function removeClassName(element, className) { if(!(element = $(element))) return false; var classes = getClassNames(element); var length = classes.length //loop through the array in reverse, deleting matching items // You loop in reverse as you're deleting items from // the array which will shorten it. for (var i = length-1; i &gt;= 0; i--) { if (classes[i] === className) { delete(classes[i]); } } element.className = classes.join(' '); return (length == classes.length ? false : true); }; window['ADS']['removeClassName'] = removeClassName; </code></pre>
javascript
[3]
3,627,746
3,627,747
Detrimental Javascript Tricks
<p>What are some of the most detrimental Javascript tricks? Pleas include the <strong>"issue seen"</strong> and "<strong>avoid by</strong>" blocks. </p> <p>Examples:</p> <ol> <li><p>Adding properties to <code>Object.prototype.prop = 1</code><br> <strong>Issue seen</strong>: <code>for(var i in obj){ alert(i);}</code><br> <strong>Avoid by</strong>: using <code>hasOwnProperty</code><br> example:<br> <code>for(var in in obj)if(obj.hasOwnProperty(i)){alert(i);}</code> </p></li> <li><p>Override <code>Number.prototype.valueOf = function(){return Math.random()}</code><br> <strong>Issue seen</strong>: <code>4*3</code> (Depends on Javascript engine)<br> <strong>Avoid by</strong>: <code>delete Number.prototype.valueof</code> (again depends on Javascript engine)</p></li> </ol> <p>Please include potential solutions if you can't think of a way to "<strong>avoid</strong>" the code.</p>
javascript
[3]
5,419,037
5,419,038
Friendly name on COM port in Java?
<p>I working on a project where I have to get access to at COM port. I'm at the moment using winjcom to get access and to list the connected devices. My problem is that I would like to have the friendly names displayed instead of just COM3, COM4 and so on.</p> <p>I found a thread </p> <p><a href="http://stackoverflow.com/questions/6362775/getting-device-driver-information-related-to-a-com-port">Getting device/driver information related to a COM port?</a> </p> <p>which can get the friendly name, but this is based on the face that i know the PID, VID and device ID. I would like to get it on all connected devices.</p> <p>Hope you guys can help me. :)</p>
java
[1]
118,030
118,031
Dynamic sub-field assignation
<p>I have some difficulties to explain my problem, some code is better than a long text:</p> <pre><code>&lt;?php $n = new stdClass(); $f = 'field[0][0]'; $n-&gt;$f = 1; var_dump($n); </code></pre> <p>The current result:</p> <pre><code>object(stdClass)#1 (1) { ["field[0][0]"]=&gt; int(1) } </code></pre> <p>The desired result:</p> <pre><code>object(stdClass)#1 (1) { ["field"]=&gt; array(1) { [0]=&gt; array(1) { [0]=&gt; int(1) } } } </code></pre> <p>Is it possible?</p> <p>Thank's in advance.</p>
php
[2]
2,752,100
2,752,101
Memory Error in Python 2.7.3
<p>I'm trying to run this program on python which simulates a mindless being going around in space and to see whether it'll reach it's target.. But I'm getting a memory error every time i run it..--</p> <pre><code>init_posn=[0,0] posn_final=[2,2] obs = [[-1,1],[-1,0],[-1,1],[0,1],[1,1],[1,0],[1,-1],[0,-1]] # algo can be improved def obs_det(posn_x,posn_y,obs): for e in obs: if e[0]==posn_x &amp; e[1]==posn_y: return 1 return 0 posn=[] posn.append(init_posn) def posn_progress(posn,posn_final,obs): i=0 non=0 while (non==0 | (posn[i][0]==posn_final[0] &amp; posn[i][1]==posn_final[1])): l=posn[i][0] m=posn[i][1] if obs_det(l,m+1,obs) == 0: posn.append([l,m+1]) elif obs_det(l+1,m,obs) == 0: posn.append([l+1,m]) elif obs_det(l,m-1,obs) == 0: posn.append([l,m-1]) elif obs_det(l-1,m,obs) == 0: posn.append([l-1,m]) else: non=1 i=i+1 if non==1: return 0 else: return posn print posn_progress(posn,posn_final,obs) </code></pre>
python
[7]
4,537,266
4,537,267
How to print Array data retrieved from Database using JQuery
<p>I am using cakePHP 1.26, and JQuery.</p> <p>In a TestingController, I got this line of code<br/></p> <pre><code>function testing(){ $r = $this-&gt;User-&gt;findallByuser_id(1); } </code></pre> <p>and I am using JQuery Ajax to retrieve the data from function testing():</p> <pre><code> $.ajax({ type: "POST", url: curl, success: function(data){ alert(data); } </code></pre> <p>Here is the JQuery Alert output: </p> <pre><code>Array </code></pre> <p>And this is cakePHP output:</p> <pre><code>Array ( [User] =&gt; Array ( [user_id] =&gt; 50 [name] =&gt; hello ) ... ) </code></pre>
jquery
[5]
901,274
901,275
Unexpected bahaviour of GetFragment and PutFragment
<p>The following is a part of the code i wrote to replace fragments using FragmentManager.</p> <pre><code> FragmentManager mFragmentManager = getFragmentManager(); if(activeFragment!=null) { mFragmentManager.putFragment(fragmentBundle,oldTabId + FRAGMENT_PREF, activeFragment); System.out.println((oldTabId + FRAGMENT_PREF) + " of type " + activeFragment.getClass().getSimpleName() + " inserted to Bundle"); } if(fragmentBundle.containsKey(newTabId + FRAGMENT_PREF)) { activeFragment = mFragmentManager.getFragment(fragmentBundle, newTabId + FRAGMENT_PREF); System.out.println((newTabId + FRAGMENT_PREF) + " of type " + activeFragment.getClass().getSimpleName() + " retrieved from Bundle"); } else { //create new fragment otherwise } if(activeFragment!=null) { //replace old fragment with new fragment. } </code></pre> <p>After inserting two fragments, any getFragment (for any key) gives a fragment of the type of the second one and also onCreateView doesnt get called.</p> <p>What am I doing wrong?</p>
android
[4]
5,044,585
5,044,586
selecting gridview rows using ctrl key
<p>I need help for selecting multiple rows in a gridview using ctrl key. (C#, asp.net)</p> <p>While right clicking on the selected rows, I need to export those particular rows to "word".</p>
asp.net
[9]
2,494,565
2,494,566
How to pass a textbox input value to another element onclick
<p>was looking for ideas/samples on how to change div styles through user input</p>
javascript
[3]
5,373,751
5,373,752
Selecting element type with attribute value in jQuery
<p>Good morning, everyone.</p> <p>Can someone please let me know the correct way to select an element type with a given attribute? In my particular case I'm trying to access a label with a an attribute of "for" that has a value of "P500_CB_TRANSFERUNIVERSITY".</p> <p>I would have though the propery jQuery syntax would be something like<br /> <code>$('label [for=P500_CB_TRANSFERUNIVERSITY]')</code> but that doesn't seem to work.</p> <p>Thanks in advance, Matt</p>
jquery
[5]
2,162,987
2,162,988
Formatting a number with leading zeros in PHP
<p>I want have a variable which contains the value 1234567.</p> <p>I want it to contain exactly 8 digits i.e. 01234567.</p> <p>Is there a PHP function for that?</p>
php
[2]
3,855,025
3,855,026
how to display the image in galleryview
<p>I create gallery view in my application. it is working fine but i want which image focused in the gallery that image also display on the screen at the same time. can anyone help for this </p> <p>Regards Raj.</p>
android
[4]
3,448,477
3,448,478
finding out which object to point to in javascript
<p>I have several global objects that contain arrays of objects; let's call these appointments. Let's say I have these objects: AppointmentsToday, Appointments02102012, Appointments02092012... I also have a global variable CurrentAppointments that holds a reference to the actual object I'm currently working on.</p> <p>The code looks somewhat like this:</p> <pre><code>var CurrentAppointments = new Object(); var AppointmentsToday = new Object(); var Appointments02102012 = new Object(); var Appointments02092012 = new Objects() ProcessNewAppointments(TheAppointments) { CurrentAppointments = TheAppointments; } SomeFunctionThatDoesWork() { .... Some code to get the array index we want to work with CurrentAppointments[i].MyProp = SomeValue; ProcessAppointments(WHAT DO I PUT THERE??); } CallingFunction() { ProcessNewAppointments(Appointments02102012); } </code></pre> <p>For instance, when I write ProcessNewAppointments(Appointments02102012) CurrentAppointments points to Appointments02102012 and when the function SomeFunctionThatDoesWork gets called, it changes the values of array Appointments02102012. So basically, when the function SomeFunctionTheDoesWork() gets called, it works on the object that's currently in CurrentAppointments, without worrying about which object to work on.</p> <p>Now what I want to do is reexecute ProcessNewAppointments after SomeFunctionThatDoesWork gets called. How can I know the name of the object CurrentAppointments is pointing to so that I can write something like <strong>ProcessNewAppointments(TheNameOfTheObjectCurrentlyInCurrentAppointments).</strong></p> <p>Thanks for your suggestions.</p>
javascript
[3]
5,207,644
5,207,645
Should I NOT include jquery on pages that do not use it?
<p>I understand that after a browser loads jquery, generally it is added to the browsers cache.</p> <p>My site has hundreds of pages and I have a header file that is included on these pages and only some of these pages use jquery code so I am wondering will a page load faster or have better performance to the end user if I do not include jquery on pages that do not use it, or since it is cached, does it not affect performance at all?</p>
jquery
[5]
215,018
215,019
How to count total number of elements in each column in a tab delimited file
<p>Given a tab delimited file, How to count total number of elements in each column? My file is ~6GB in size. </p> <pre><code>column count min max sum mean 80 29573061 2 40 855179253 28.92 81 28861459 2 40 802912711 27.82 82 40 778234605 27.63 83 27479902 2 40 27.44 84 26800815 40 729443846 27.22 85 26127825 2 701704155 26.86 </code></pre> <p>Output:</p> <pre><code>`column` has 6 items in it `count` has 5 items in it and so on </code></pre>
python
[7]
2,921,962
2,921,963
why javascript's charAt() with a string returns the first letter
<p>I am doing some exercises in my object-oriented javascript book, I notice that this:</p> <pre><code>var a = "hello"; a.charAt('e'); // 'h' a.charAt('adfadf'); //'h' </code></pre> <p>Why is the string in the argument seemingly evaluated to the integer 0 for the charAt() method for strings?</p> <p>Edit: I was aware that the charAt()'s usage usually takes an integer, and the exercise feeds charAt() with a string, and I also was aware that the string is likely then to be coerced into an integer first, which I did verify to be NaN. Thanks Kendall, for suggesting putting this missing bit of information in the question proper</p> <p>Thanks!</p>
javascript
[3]
911,590
911,591
ACL not getting inherited
<pre><code>var ac = directoryInfo.GetAccessControl(); var wid = WindowsIdentity.GetCurrent(); IdentityReference securityIdentifier = (wid == null) ? new SecurityIdentifier(WellKnownSidType.BuiltinUsersSid, null) : wid.User; bool result = false; ac.ModifyAccessRule(AccessControlModification.RemoveAll, new FileSystemAccessRule( securityIdentifier, FileSystemRights.FullControl, InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit, PropagationFlags.None, AccessControlType.Deny), out result); //check result result = false; ac.ModifyAccessRule(AccessControlModification.Set, new FileSystemAccessRule( securityIdentifier, FileSystemRights.FullControl, InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit, PropagationFlags.None, AccessControlType.Allow), out result); //check result directoryInfo.SetAccessControl(ac); </code></pre> <p>I have code above to set directory permission to full control and at the same time remove any "deny" permission set. This code works for the current directory but it's not propagated to child directories and files, anything wrong?</p> <p>Note that I'm checking the "result" after each ModifyAccessRule call and I can see that they're set to true both times.</p>
c#
[0]
715,259
715,260
class with virtual functions takes more place
<p>There is such code:</p> <pre><code>#include &lt;iostream&gt; class A{ int a; int fun(){} }; class B{ int a; virtual int fun(){} }; int main() { std::cout &lt;&lt; sizeof(A) &lt;&lt; " " &lt;&lt; sizeof(B) &lt;&lt; std::endl; std::cin.get(); return 0; } </code></pre> <p>The output is:</p> <pre><code>4 8 </code></pre> <p>Why class B is 4 bytes bigger than class A?</p>
c++
[6]
399,571
399,572
Where is an event registered with addEventListener stored?
<p>I start with an empty page. If I run <code>document.body.onclick</code> I get <code>null</code>. If I apply following code:</p> <pre><code>document.body.onclick = function() { return "Click"; }; </code></pre> <p>I get <code>function() { return "Click"; }</code> when I run <code>document.body.onclick</code>. That makes sense! But when I run</p> <pre><code>document.body.addEventListener("click", function() { return "Click"; }); </code></pre> <p><code>document.body.onclick</code> is still <code>null</code>, but the output is <code>"Click"</code> when I run <code>document.body.click()</code>.</p> <p><strong>So my question is, where is the function stored when using <code>addEventListener</code>?</strong></p>
javascript
[3]
2,105,136
2,105,137
Can we add images into outlook mail using php?
<p>I have a Create task page. So once Task is created, and if user admin clicks mail button. Outlook will open and add the subject and body which I typed. </p> <p>But my doubt is can I add an image and also can we change teh font color in Message using code itself. I am a newbie in this thats why the dumb doubt.</p> <pre><code>&lt;a href="mailto:xxxx@xxxx.com?subject=Any Subject&amp;body= Any Topics"&gt;Mail&lt;/a&gt;&gt; </code></pre>
php
[2]
3,431,843
3,431,844
Can jquery tell me which image is shown when .cycle stops?
<p>I have 5 images inside a single div and I'm using jquery's .cycle plugin to cycle through them. Is there a way jquery can tell me which image the cycle stopped on?</p> <p>Heres my html...</p> <pre><code> &lt;div id="slot1"&gt; &lt;li id="reel1a"&gt;&lt;img src="reel1a.jpg" /&gt;&lt;/li&gt; &lt;li id="reel1b"&gt;&lt;img src="reel1b.jpg" /&gt;&lt;/li&gt; &lt;li id="reel1c"&gt;&lt;img src="reel1c.jpg" /&gt;&lt;/li&gt; &lt;li id="reel1d"&gt;&lt;img src="reel1d.jpg" /&gt;&lt;/li&gt; &lt;li id="reel1e"&gt;&lt;img src="reel1e.jpg" /&gt;&lt;/li&gt; &lt;/div&gt; </code></pre>
jquery
[5]
2,392,660
2,392,661
Undefined Javascript variable
<p>So here is the problem. There is a HTML/JS code, but I can't read v3 variable. In short anything after <code>DDDD(D,{"COM":"lng","leaf":145,"AXIS":true});</code> (which is some kind of predefined random array) is unreadable(or ignored as JS code). Why? And how can i get contents of v3? Is this a javascript parse bug?</p> <pre><code>&lt;html&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt; &lt;head&gt; &lt;script type="text/javascript"&gt; &lt;!-- var v1 = 12345; var v2 = "Hello world"; DDDD(D,{"COM":"lng","leaf":145,"AXIS":true}); var v3 = "World Hello!!!"; //--&gt; &lt;/script&gt; &lt;/head&gt; &lt;!-- some html code --&gt; &lt;script&gt; alert("This is "+v3); &lt;/script&gt; &lt;!-- some html code --&gt; &lt;/html&gt; </code></pre>
javascript
[3]
5,399,417
5,399,418
how to take image in byte[] format from drawable folder?
<p>I want to take the image from drawable folder but it should be in the byte[] format.So that i can save that byte[] into the database.I have gone through links but that is taking image from drawable folder in String or Drawable format. Any suggestion for me plz..</p>
android
[4]
4,138,421
4,138,422
To start our application when user selects a file to share
<p>I am developing an application to share files between two devices. My task is to pin my application to the 'share menu' or 'send via menu' so that my application get started when the user want to share it through my application.</p> <p>If anybody knows how to resolve this please answer.</p> <p>Thanks</p>
android
[4]
4,252,790
4,252,791
C Programming, Variables
<p>When we declare variables in a class and then when we assign the value of those variables, for example like this </p> <pre><code>class c { public : int x; int x2; c () { x = 0; x2 = 0; scanf ("%d", &amp;x); and now we're gonna input for example 10 } }; </code></pre> <p>each time the class is used, I mean each time the constructor is called, the value of x becomes 0 again since it is initialized as zero in the constructor. However if we don't initialize the value, there will be errors.</p> <p>My question is that how can we keep the value of the variable when we call the constructor again and again so that it doesn't become zero ? </p> <p>Edit:</p> <pre><code>void example () { int i; scanf ("%d", &amp;i); switch (i) { case 1 : {Object ob1; system ("cls"); menu ();} // this object contains a value like 20 case 2 : {Object ob2; system ("cls"); menu ();} } } </code></pre> <p>There is another switch case in Object 1 which includes an option to go back to a main menu, now if I enter 1 again go back to object 1 I cannot see the value 20, it will be 0</p>
c++
[6]
2,781,723
2,781,724
How to attach request parameters to current Android HttpUrlConnection call
<p>I am able to send a request from an Android program to a remote server, but it seems the request has no parameters. How do I attach parameters?</p> <p>Here is my current code:</p> <pre><code> @Override protected String doInBackground(String... theParams) { String myUrl = theParams[0]; final String myEmail = theParams[1]; final String myPassword = theParams[2]; Authenticator.setDefault(new Authenticator() { protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication( myEmail, myPassword.toCharArray()); } }); String response = null; try { final URL url = new URL(myUrl); final HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestProperty("login", myEmail); conn.setRequestProperty("password", myPassword); conn.setUseCaches(false); final InputStream is = conn.getInputStream(); final byte[] buffer = new byte[8196]; int readCount; final StringBuilder builder = new StringBuilder(); while ((readCount = is.read(buffer)) &gt; -1) { builder.append(new String(buffer, 0, readCount)); } response = builder.toString(); Log.d( "After call, response: " , " " + response); } catch (Exception e) { } return response; } </code></pre> <p>So now I am not sure how to make the Authenticator password/login get attached to the request and get sent to the server. Any idea how I can accomplish that?</p> <p>Thanks!</p>
android
[4]
5,305,565
5,305,566
How to save bitmap in database?
<p>I want to know how to save a bitmap in database. I created table in db as:</p> <pre><code>@Override public void onCreate(SQLiteDatabase db) { db.execSQL("CREATE TABLE " + TABLE_NAME + " (_id INTEGER PRIMARY KEY AUTOINCREMENT,image BLOB)"); } </code></pre> <p>My problem is I am not able to insert the image. Please tell me in which format I need to insert the image.</p>
android
[4]
3,011,891
3,011,892
Why {}.toString can check data type?
<p>Can anyone explain a bit about why these codes can check data type? They does not make sense to me. I cannot understand what the codes do behind the scene. Thanks in advance!</p> <pre><code>var toClass = {}.toString // {} is for what? toString is a method? alert(toClass); // alert it I get a function? = &gt; function toString() {[native code]} alert( toClass.call( [1,2] ) ) alert( toClass.call( new Date ) ) </code></pre>
javascript
[3]
3,087,347
3,087,348
setContentView not executed after onRestoreInstanceState
<p>I have the following problem:</p> <p>After <code>onRestoreInstanceState</code> is called, I notice that while <code>setContentView</code> is supposed to be called, I keep getting all sorts of exceptions that imply that <code>setContentView</code> isn't executed - missing <code>findViewById</code>, <code>getWindow().setFeatureInt()</code> throwing exception because content view isn't called, black screen instead of the actual screen I am expecting, etc.</p> <p>Am I doing something wrong here?</p> <p>Thanks</p>
android
[4]
1,629,993
1,629,994
Is it right to think of a Javascript Function Expression that uses the 'new' keyword as 'static'
<p>I'm just trying to understand Javascript a little deeper. </p> <p>I created a 'class' <code>gameData</code> that I only want ONE of, doesn't need a constructor, or instantiated.</p> <p>So I created it like so...</p> <pre><code>var gameData = new function () { //May need this later this.init = function () { }; this.storageAvailable = function () { if (typeof (Storage) !== "undefined") { return true; } else { return false; } }; } </code></pre> <p>Realizing that the 'new' keyword doesn't allow it to be instantiated and makes it available LIKE a static class would be in C#. </p> <p>Am I thinking of this correctly? As static?</p>
javascript
[3]
938,365
938,366
How to display text at runtime throught LightBox
<p>how to show few text in light box instead of image. i found that most of the time light box is used to show images but i want to show text or suppose a asp.net gridview inside a light box. i found jquery light box plugin available the url is <a href="http://leandrovieira.com/projects/jquery/lightbox/" rel="nofollow">http://leandrovieira.com/projects/jquery/lightbox/</a>. from here sample i did not find any way to show text in light box instead of image . So please tell me how to show text in light box instead of image and the text i will pass at run time.</p> <p>thanks.</p>
jquery
[5]
267,800
267,801
display a bg image in table view for iphone
<p>i can display BG image in table view cell but when i click any cell there is a blue color filling all my cell and my images just goes behind now i want to show my image in front of that blue color how to do that??</p> <pre><code>cell.backgroundView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"SuperCell.png"]] autorelease]; </code></pre>
iphone
[8]
2,672,516
2,672,517
how to show progress bar moving from one activity to another activity in android
<p>I want to show progress bar to going from one activity to another activity until another activity is loaded can anybody give example</p> <p>Thanks</p>
android
[4]
5,568,172
5,568,173
Is it possible to have variables visible "only to modules" and its extensions?
<p>Say I have the following modules, split across multiple files both capable of <em>extending</em> <code>skillet</code>:</p> <p><strong>File1.js:</strong></p> <pre><code>(function(){ var privateVar1 = 0; var privateFunction1 = function() { //function definiton }; skillet.fry() = function() { //fry it //matchbox.light(); }; })(window.skillet = window.skillet || {}); </code></pre> <p><strong>File2.js:</strong></p> <pre><code>(function(){ var privateVar2 = 0; var privateFunction2 = function() { //some private function }; skillet.grillIt = function() { //grill It //matchbox.strike(); &lt;-- Shared with File1.js }; })(window.skillet = window.skillet || {}); </code></pre> <p>Is it possible to have a shared variable/object like <code>matchbox</code> be sharable by the two modules <strong>without</strong> being bound to <code>window.matchbox</code> or <code>window.skillet.matchbox</code>? I.e. the <em>visibility</em> of <code>matchbox</code> should only be to File1.js and File2.js and must not be accessible elsewhere. I doubt if it's possible, but is there a way to achieve such a behavior in JavaScript? If not, what's the best practice to use in this regard?</p> <p>(It's more like having a shared <em>event-bus</em> among a set of related modules without exposing that bus globally)</p>
javascript
[3]
5,985,559
5,985,560
timer issue at getting previous view
<p>hi i am new to iPhone development. what i am doing is displaying 20 images as grid and each image treat as button,by selecting that image it will be displayed on image view "here what i needed is i using timer to get back to grid but there is [NSCFArray ObjectAtIndex]: index(4) beyond bounds(4) and application terminates" how can i slove this problem pls help me</p>
iphone
[8]
172,823
172,824
How do I control the behavior of window.location in Javascript?
<p>At the bottom of my page I have window.location = ...</p> <p>I wish my page (let's call it jspage) to load, and then only once everything is fully loaded do the redirect. At the moment I get "stuck" on the referring page while jspage is processing, then jspage flashes up for a tiny instant and I am redirected</p>
javascript
[3]
2,937,454
2,937,455
How to check in an entered value is from autocomplete?
<p>I have a jquery's autocomplete texbox and, upon a click of a button, I need to check if the value entered has come from the autocomplete or is it a completely new value.</p> <p>The problems is that my code constantly gives me 'alert("no")'... maybe I shouldn't be checking against 'cache', but something else?</p> <pre><code>//////////////////////////////////////////// autocomplete code ////////////////// var cache = {}, lastXhr; $( "#inputV" ).autocomplete({ minLength: 2, source: function( request, response ) { var term = request.term; if ( term in cache ) { response( cache[ term ] ); return; } lastXhr = $.getJSON( "search.php", request, function( data, status, xhr ) { cache[ term ] = data; if ( xhr === lastXhr ) { response( data ); } }); } }); ////////////////////////// check if input comes from autocomplete ////////////////// $('#btn_check').click(function() { var input = $("#inputV").val(); alert(input); if ( input in cache ) { alert("yes"); } else { alert("no"); } }); </code></pre> <p><img src="http://i.stack.imgur.com/Z5eYF.jpg" alt="enter image description here"></p>
jquery
[5]
2,376,627
2,376,628
JQuery only highlight prepended text
<p>I need to highlight the text that I prepend; not the entire string. My code below highlights everything.</p> <pre><code>jQuery("#foo").prepend("&lt;li&gt;Addition li&lt;/li&gt;").effect("highlight", {}, 1000) </code></pre> <p>So I only want to highlight that new <li>. How can I do this?</p>
jquery
[5]
3,399,349
3,399,350
Destructors and constructors
<p>Would someone please explain to me why I get an "Error: not declared in this scope?"</p> <p>num and denom are private members of class Rationalnumber.</p> <p>Thanks!</p> <pre><code>Rationalnumber::Rationalnumber(){ num = 0; denom = 1; int * n = new int; int * d = new int; *n = num; *d = denom; } Rationalnumber::~Rationalnumber(){ delete n; } </code></pre>
c++
[6]
4,652,703
4,652,704
Java: how do I spawn multiple threads on each processor core?
<p>I have a java app, and, I want it to take advantage of multicore processors, how do I take advantage of them? Does just spawning a new thread do the trick? Like does the OS decide what core to put the thread on?</p>
java
[1]
162,071
162,072
Simple code? PHP script pulls update.zip from central server and extracts it to local folder!
<p>Can someone post code or point to a working example of a php script that opens a known zip file located on a remote server (via http) and extracts the contents of that zip file to a folder on the same server as the calling script?</p> <pre><code>Server A calls out for zip file located on Server B Server B sends the zip file over to server A Server A extracts the contents of the Zip to Directory C (pub_html) on Server A </code></pre> <p>I've been going around and around on how to get this to work and it really seems like it should be super simple with lots of examples, but I can find none.</p>
php
[2]
4,396,172
4,396,173
Jquery select only neighbor
<p>I've got:</p> <pre><code>&lt;div class="row even"&gt; &lt;div class="more"&gt;more&lt;/div&gt; &lt;div class="body"&gt;Some additional text&lt;/div&gt; &lt;/div&gt; &lt;div class="row odd"&gt; &lt;div class="more"&gt;more&lt;/div&gt; &lt;div class="body"&gt;Anoteher text&lt;/div&gt; &lt;/div&gt; </code></pre> <p>And I want to toggle div with "body" class when "more" div is clicked but only in their common row class.</p> <pre><code>$('.more').click(function() { $('.body').toggle(); }); </code></pre> <p>But it toggle all div with "body" class.</p>
jquery
[5]
2,662,377
2,662,378
Getting a value of a site
<p>So as the title says I want to get a value of this site : <a href="http://xtremetop100.com/conquer-online" rel="nofollow">Xtremetop100 Conquer-Online</a></p> <p>My server is called Zath-Co and right now we are on rank 11. What I want is that a script is going to tell me which rank we are, how much in's and out's we have. Only thing is we are getting up and down in the list so I want a script that checks on the name not at the rank, but I can't come out of it. I tried this script </p> <pre><code> &lt;?php $lines = file('http://xtremetop100.com/conquer-online'); while ($line = array_shift($lines)) { if (strpos($line, 'Zath-Co') !== false) break; } print_r(explode(" ", $line)); ?&gt; </code></pre> <p>But it is only showing the name of my server and the description. How can I get this to work as I want or do I have to use something really different. (If yes then what to use, and a example would be great.)</p>
php
[2]
1,967,647
1,967,648
mediaplayer start and stop within dialog
<p>I've an "info" dialog and I'd like add background music. I added my music in res/raw, just open dialog there's a check by sharedpreferences. So, when an users click on "info", automatically start music, next when users click on "ok" music should be stops.</p> <p>My code, but does not runs.</p> <pre><code>private void Info(){ sob(); LayoutInflater li = LayoutInflater.from(this); View view = li.inflate(R.layout.info, null); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setView(view).create(); TextView text=(TextView) findViewById(R.id.infoView1); builder.setCancelable(false); builder.setPositiveButton("Chiudi", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Info = 0; //checkmp=1; sob(); dialog.cancel(); } }); builder.show(); } public void sob(){ MediaPlayer mp = MediaPlayer.create(this, R.raw.sob); SharedPreferences prefs = getSharedPreferences(PRIVATE_PREF, 0); int sob = prefs.getInt("sob", 0); if (sob == 0){ mp.start(); SharedPreferences.Editor editor = prefs.edit(); editor.putInt("sob", 1); editor.commit(); } else { mp.stop(); SharedPreferences.Editor editor = prefs.edit(); editor.putInt("sob", 0); editor.commit(); } } </code></pre>
android
[4]