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,561,910
1,561,911
How to work with TranslateAnimation in android?
<p>I have moved the button from left to right using TranslateAnimation but after that button click listiner is not working for new location . </p>
android
[4]
5,368,720
5,368,721
question related to Autorotation
<p>hi when i delete the application and then on first page if i rotate from portrait landscape then it rotates but on second time it not why?</p>
iphone
[8]
3,478,254
3,478,255
private constructor usage in class
<p>If there is a private constructor, does the JVM insert a call to the super constructor? </p> <p>I'm referring to the <code>super()</code> call in that private constructor.</p> <pre><code>class Alpha { static String s=""; protected Alpha(){ s+="alpha"; } } class SubAlpha extends Alpha{ private SubAlpha(){ s+="sub"; } } class SubSubAlpha extends Alpha{ private SubSubAlpha(){ s+="subsubAlpha"; } public static void main(String[] args){ new SubSubAlpha(); System.out.print(s); } } </code></pre> <p>Here I don't get any compilation error. Here in the <code>SubSubAlpha</code> class there is private constructor. Is that compiler insert <code>super()</code> call in that if so, what happens in the <code>SubAlpha</code> class. Even there is private constructor. And if that is not accessed how the inheritance tree continues till the top.</p>
java
[1]
3,310,090
3,310,091
number logic program needed for id generation
<p>program to output <strong>all 4 digit numbers</strong> where no prior digit is greater than latter.</p> <p>Numbers should be 1-9(including 1 &amp; 9).</p> <p>Numbers can be like 1234,2345. First digit should be less than second, second should be less than third, third should be less than fourth.</p>
php
[2]
3,744,401
3,744,402
layout margin for text view programmatically
<p>If I use xml file I have a option called layout_margin (for example layout_margin ="1dp" for text view ) but I want to set programmatically and I dont know how to do it.</p>
android
[4]
2,007,356
2,007,357
using printrand within a url?
<p>is there any way to use printrand() or something similar to generate random numbers from inside of a url call in a php script or html page? Basically, have a url, but on each load, I need the page to call url(dot)com/blah####blah with the #s being random each time.... How can I accomplish this?</p>
php
[2]
2,199,335
2,199,336
Jquery plugin scope question (closures)
<p>I'm trying to make a plugin and am running into some problems:</p> <pre><code>(function($){ var users = {}; $.fn.plugin = function(){ //blah, but alters users } $.fn.utility_function = function(){ // uses users } }); </code></pre> <p>What's happening is that when I run two instances of this plugin, "users" ends up having the same value for each instance of the plugin. How do I make them unique?</p>
jquery
[5]
2,523,058
2,523,059
Android ftp download failure from HTC to Samsung
<p>i had uploaded .3gp videofile from HTC legent using FTP and download it in samsung but the download file shows unsupported.But when use same mobile for upload and download it works fine.can any one help me?</p>
android
[4]
4,833,164
4,833,165
extract left of the question mark
<p>Is there a quick way to grab everything left of the question mark?</p> <pre><code>http://blah/blah/?blah to http://blah/blah/ </code></pre>
c#
[0]
3,444,592
3,444,593
Finding Device width
<p>How to find the device width using the view port meta tag. </p> <p>Also wants to display the device width in the console with </p> <p>java script.</p>
javascript
[3]
4,933,361
4,933,362
Getting the Variables of a function listed in the construct?
<p>I'm not an amazing developer so please bear with me, but I've begun using classes and functions, and I really like how I can write a library. A single page where all my PHP can go. I was thinking though, my life would be a millon times easier if I could check the variables of a function in the construct, and escape them all before running the function. That way, I wouldn't have to escape each variable for each function.</p> <p>I'd need to be able to have the construct somehow check and see what the variables are in the function, and then escape them. </p> <pre><code>so X = 'Variable for a function' X = mysqli_real_escape_String($conn, X); </code></pre> <p>Could anyone please tell me if this is possible, and if not, what other options could you suggest? </p> <p>P.S. I'm not advanced enough to use PDO yet, so please keep the advice to procedural programming.</p> <p>Sorry, perhaps I'm not explaining this correctly. What I'm trying to do is eliminate the need to escape variables in my library that come when someone calls a function($vars). So the idea is to write some type of script within the __construct that will check the $vars and escape them before the function is ran. </p> <pre><code>class users { function __construct() { //the idea is that i can somehow escape the variables within the function //for the function that's being called function magical_funtion_that_calls_all_variables() { foreach($var) { $var = mysqli_real_escape_string($conn, $var); } } } function register($user, $pass1, $pass2) { </code></pre>
php
[2]
1,739,257
1,739,258
Most efficient way to obtain data from a list of objects?
<p>I have a list of objects like this (created from PHP then json encoded):</p> <pre><code>{"10":{"10":["4","7","2","2","0","32"],"11":["5","22","1","1","0","0"]}} translated: {"X":{"Y":["unique_id","data","data","data","data","data"],"Y":["unique_id","data","data","data","data","data"] </code></pre> <p>But im trying to find a way to obtain the X:Y by looking for the unique_id lets say it was 4.</p> <p>What would be the most efficient way to do this ?</p>
javascript
[3]
1,778,972
1,778,973
click on a mapview marker to open a certain actvity-android development
<p>Here's my prob,what i would like to do is to click on a gmap marker and that should take me to another activity. as long as i know i should use the method onTap but i don't really getting how i should do it. here's my code:</p> <pre><code> protected boolean onTap(int index) { SAXParserActivity saxParser = new SAXParserActivity (); Bundle bundle = new Bundle(); bundle.putDouble("Latitude",saxParser.gp[index].getLatitudeE6()/1E6); bundle.putDouble("Longitude", saxParser.gp[index].getLongitudeE6()/1E6); bundle.putDouble("CurrentLatitude",33.8761673); bundle.putDouble("CurrentLongitude",35.54236984); Intent intent = new Intent(mContext, ListItemsMapRouteActivity.class); intent.putExtras(bundle); ((MapActivity)mContext).startActivityForResult(intent, 0); return true; } </code></pre> <p>well the saxParser is suppose to get me all the gaz_stations around me,which will let me take the lon and lat, and i want these to be sent to ListItemsMapRoutActivity when clicking on a marker ... plz i would appreciate any help,i'm kinda stuck here. thank you !</p>
android
[4]
5,164,989
5,164,990
Android video streaming Socket MediaRecorder (Broadcasting)
<p>I'm beginner work with android. But I very need your help. I have a project with streaming video Broadcasting video. I can not find good sample, where will be realized recording Video from Camera, sending (uploading) stream to server and downloading (getting streaM) from server to Player. Please help me with this questions Thanks.</p>
android
[4]
809,880
809,881
Need to know when it's a new day, i.e., when the time is 00:00:00
<p>I think I read somewhere that there's a system event for when the time changes (each second?) but are there other levels of granularity such as when the hour changes?</p> <p>I have a <code>TabActivity</code> for a 7 day TV Guide - the indicator for the first (leftmost) always shows 'Today' with the others showing a three-letter day (Mon, Tue, Wed etc) obviously depending on what the day is today.</p> <p>What I'd like to do is have the activity 'know' when midnight comes so it pops up a 'Re-loading please wait...' <code>ProgressDialog</code> and adjusts the indicator on each tab and the associated tab contents.</p> <p>Is there a built-in system event that can help or is <code>AlarmManager</code> my best approach?</p>
android
[4]
3,685,121
3,685,122
php exceptions extra parameters
<p>Is it possible to add an extra parameter when trowing an exception?</p> <p>When i trow an exception I send along the error message but i would also like to send along the name of the field in a extra parameter. Something like</p> <pre><code>throw new Exception('this is an error message', 'the field'); </code></pre> <p>So when i display the message i can do something like this </p> <pre><code>show_error($e-&gt;getFieldname, $e-&gt;getMessage()); </code></pre>
php
[2]
29,590
29,591
javascript image problem
<p>how cand i add a value to the class element in an image?</p> <p>for src and align it works, and it adds the values to src and align:</p> <pre><code>src : this.inputs['src'].value, align : this.inputs['align'].value, </code></pre> <p>but when i write class it becomes highlighted and it dosen't add the value to the class element in the images html:</p> <pre><code>class: this.inputs['class'].value, </code></pre> <p>is 'class' a reserved word in javascript? if yes is there another solution for my prolem?</p>
javascript
[3]
1,321,329
1,321,330
Mapping Execution of Program
<p>I am learning Java, and I was wondering whether there was some way of "mapping" the execution of a Java piece of code.</p> <p>Ie:</p> <p>Some kind of software which step by step executed the program and returned something like:</p> <p>At line x this method is called and changed variable a from value b to value c.</p> <p>etc.</p> <p>Cheers!</p>
java
[1]
2,112,332
2,112,333
Javascript history does not work
<pre><code>document.addEventListener('DOMContentLoaded', function () { displayRecentUrls("recentUrls"); }); function displayRecentUrls(divName) { var popup = document.getElementById(divName); var ul = document.createElement("ul"); popup.appendChild(ul); var microsecondsPerWeek = 1000 * 60 * 60 * 24 * 7; var oneWeekAgo = (new Date).getTime() - microsecondsPerWeek; history.search({ 'text': '', 'startTime': oneWeekAgo }, function(historyItems) { for (var i = 0; i &lt; historyItems.length; ++i) { var url = historyItems[i].url; var li = document.createElement("li"); ul.appendChild(li); var a = document.createElement("a"); a.href = url; a.appendChild(document.createTextNode(url)); li.appendChild(a); } }); } </code></pre> <p>I wrote the code above to generate the browsing history for one week. It does not work. I'm new to Javascript so I may have made a silly mistake.</p>
javascript
[3]
2,848,462
2,848,463
Python: has_key , I want to print the value of the key with if statement
<p>could you please help me with this.</p> <p>I want to print the value of the key with if statement. it is have one OR other value if it is not , but not for one , for all.</p> <p>my try:</p> <pre><code>wp = {'tomatos': , 'patotoes': , 'milk':0.5'cheese':, 'eggs':0.25,'meat':2} x= ' item is not available in this store' </code></pre> <p>how I can make my output like this ?</p> <blockquote> <p>tomatos item is not available in this store.</p> <p>patotoes item is not available in this store.</p> <p>milk 0.5</p> <p>cheese item is not available in this store .</p> <p>eggs 0.25 </p> <p>meat 2</p> </blockquote> <p>thats mean if any Item in the list dont have price , print x infront of it , and for others print the price shown .</p>
python
[7]
1,331,099
1,331,100
Operators vs Functions in C/C++
<p>Someone recently asked me the difference between a C++ standard operator (e.g. new,delete,sizeof) and function (e.g. tan,free, malloc). By "standard" I mean those provided by default by the compiler suite, and <em>not user defined</em>. Below were the answers I gave, though neither seemed satisfactory.</p> <p>(1) An operator doesn't need any headers to be included to use it : E.g. you can have a call to new without including any headers. However, a function (say free() ) does need headers included, compulsorily. </p> <p>(2) An operator is defined as such (ie as a class operator) somewhere in the standard headers. A function isn't. </p> <p>Can you critique these answers and give me a better idea of the difference?</p>
c++
[6]
4,638,611
4,638,612
dynamic alertdialog with radio buttons
<p>I am trying to make the item list dynamic, so i can add to it on runtime, but i have no idea. CharSeqence isnt dynamic, and no clue how to use the adapter option, how could i change my code to be dynamic? </p> <pre><code>private void alertDialogLoadFile() { AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle("Choose:"); CharSequence[] items = { "moshe", "yosi", "ee" }; alert.setSingleChoiceItems(m_items , -1, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item){ /* User clicked on a radio button do some stuff */ } }); alert.setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { } }); alert.setNegativeButton("No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog ad = alert.create(); ad.show(); } </code></pre>
android
[4]
3,208,657
3,208,658
Error when binding gridview data to a datatable
<p>I've a gridview in which i bind some data to it.After binding it i want to get the gridview content in a new data table.</p> <p>Here's my c# code</p> <pre><code> Datatable dt_NewTable = new DataTable(); foreach (GridViewRow gvRow in gdMainDetails.Rows) { DataRow dr = dt_NewTable.NewRow(); for (int i = 0; i &lt; gvRow.Cells.Count; i++) { dr[i] = gvRow.Cells[i].Text; } dt_NewTable.Rows.Add(dr); } </code></pre> <p>The problem is that i'm getting 'gvRow.Cells[i].Text' as "". What's the problem ?? </p>
c#
[0]
5,173,444
5,173,445
JQuery center plug-in which extend the functionality
<p>i got a piece of code for centering any element by jquery.</p> <pre><code>(function($){ $.fn.centerIt = function(settings){ var opts = $.extend({}, $.fn.centerIt.defaults, settings); return this.each(function(settings){ var options = $.extend({}, opts, $(this).data()); var $this = $(this); $this.css({ position:options.position, top:'50%', left:'50%', width:options.width, // adjust width height:options.height, // adjust height zIndex:1000, marginTop:parseInt((options.height / 2), 10) + 'px' // half of height marginLeft:parseInt((options.width / 2), 10) + 'px' // half of height }); }); } // plugin defaults - added as a property on our plugin function $.fn.centerIt.defaults = { width: '600px', height: '600px', position:'absolute' } })(jQuery); $('#elementId').centerIt({width:'400px', height:'200px'}); </code></pre> <p>this code is not working properly. just tell me what is wrong and what to rectify as a result it will work fine....thanks.</p>
jquery
[5]
4,354,625
4,354,626
How can I leave a message in crashlog when I catch an exception?
<p>I want to leave a message in crashlog when I catch an exception. Does NSLog() work?</p>
iphone
[8]
682,258
682,259
Check which php functions will work in a specific php version
<p>At least this shows I'm not afraid to look stupid. Here it goes: At some point while writing my php project, I determined that it would need php verion 5.2 to work properly. I didn't document why. Now, a user is asking me what will break if they run my app on 5.1 and I simply can't remember.</p> <p>Is there any automated way to check which functions will fail using 5.1. I looked at PHP_CodeSniffer, but I'm not sure that will do what I want. Any thoughts?</p>
php
[2]
63,674
63,675
Problem in Datetime conversion in c#
<p>I have a problem while converting a string whose value is <code>dd.mm.yyyy</code> to <code>DateTime</code> in c#</p> <pre><code>string OriginalDateFormat = "28.06.2009"; DateTime dt= Convert.ToDateTime(OriginalDateFormat); </code></pre> <p>Throwing an exception <code>"String was not recognized as a valid DateTime."</code></p> <p>But if it is in <code>mm.dd.yyyy</code> then it is running fine.</p> <p>I googled and got lots of sites but all in vain</p> <p>Any idea?</p> <p>Thanks in advance.</p>
c#
[0]
928,869
928,870
UITableView Selection & Deselection
<p>I am having two tableviews if the 1st table row gets selected then automatically deselect the row in 2nd table if it is previously selected. Kindly anyone help me in this. Thanx in advance.</p>
iphone
[8]
2,236,583
2,236,584
Receive intent when user clears data
<p>is it possible to receive some intent, when user clicks "Clear data" button in Manage Application section while app is running?</p>
android
[4]
595,736
595,737
How to convert MS Access date to string in C#
<p>I was able to gather data from Access into my texboxes, but the dates won't stop giving errors. Is there a way to grab dates or is that impossible? No where on this site can I find a souluiton to convert dates to strings to display into a textbox. Any help would be great or I have to change the database dates to strings.</p> <p>//Dates not displaying, only errors in the while loop //strBirthday = dr["STU_BIRTHDAY"].ToString(); This won't diplay like the other 2 strings. </p> <p>protected void btnQuery_Click(object sender, EventArgs e) { OleDbConnection con = new OleDbConnection("Provider = Microsoft.ACE.OLEDB.12.0; Data Source = C:\collection\database.accdb"); string strQueryString = "SELECT STU_NAME, STU_ADDRESS, STU_BIRTHDATE FROM Students WHERE STU_ID = @SID"; OleDbCommand com = new OleDbCommand(strQueryString, con); com.Parameters.AddWithValue("SID", txtStuID.Text.Trim()); con.Open(); OleDbDataReader dr = com.ExecuteReader();</p> <pre><code> string strName = ""; string strAddress = ""; string strBirthday = ""; while (dr.Read()) { strName = dr["STU_NAME"].ToString(); strAddress = dr["STU_ADDRESS"].ToString(); strBirthday = dr["STU_BIRTHDAY"].ToString(); } txtStuName.Text = strName; txtStuAddress.Text = strAddress; txtStuBirthDate.Text = strBirthday; dr.Close(); con.Close(); } </code></pre>
asp.net
[9]
1,513,929
1,513,930
How to have exceptions that doesn't need to be caught in Java?
<p>I would like to throw a custom exception that will be determined at runtime. Currently I have to either add throws to the function or surround it with a try catch. What I want is for this exception to not be caught at all. It is a fatal exception and will show the programmer the error and what he can do to fix it. This is for an abstract class checking if initialization has been run first. I would like it to act like a NullPointerException, as when it occurs the program crashes.</p> <p>Thanks</p>
java
[1]
3,568,810
3,568,811
create a pathName
<p>I want to get the image of a path, but if I use this:</p> <pre><code>String pathname="/path/img.png"; </code></pre> <p>If I use the following method:</p> <pre><code>Bitmap icon = BitmapFactory.decodeFile (pathname); </code></pre> <p>The variable icon returns me null.</p> <p>I don't know to create the pathname.</p> <p>Thanks. Regards</p>
android
[4]
260,897
260,898
Below LinearLayout Not Showing?
<p>Only ScrollView is visible?Y so? </p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;&lt;LinearLayout android:id="@+id/LinearLayout01" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android"&gt; &lt;ScrollView android:id="@+id/ScrollView01" android:layout_width="fill_parent" android:layout_height="110px"&gt; &lt;LinearLayout android:id="@+id/LinearLayout02" android:layout_width="wrap_content" android:layout_height="30px" android:orientation="vertical"&gt; &lt;Button android:text="1" android:id="@+id/Button01" android:layout_width="wrap_content" android:layout_height="wrap_content" /&gt; &lt;Button android:text="2" android:id="@+id/Button02" android:layout_width="wrap_content" android:layout_height="wrap_content" /&gt; &lt;Button android:text="3" android:id="@+id/Button03" android:layout_width="wrap_content" android:layout_height="wrap_content" /&gt; &lt;/LinearLayout&gt; &lt;/ScrollView&gt; &lt;LinearLayout android:id="@+id/LinearLayout02" android:layout_width="wrap_content" android:layout_height="30px" android:orientation="vertical"&gt; &lt;Button android:text="1" android:id="@+id/Button01" android:layout_width="wrap_content" android:layout_height="wrap_content" /&gt; &lt;Button android:text="2" android:id="@+id/Button02" android:layout_width="wrap_content" android:layout_height="wrap_content" /&gt; &lt;Button android:text="3" android:id="@+id/Button03" android:layout_width="wrap_content" android:layout_height="wrap_content" /&gt; &lt;/LinearLayout&gt; </code></pre> <p></p>
android
[4]
748,858
748,859
Need explanation for the jquery code
<p>i got a code which can be used to notify user when all images download complete but the flow of the code is not very clear to me. can anyone explain please in detail.</p> <p>what one() function and what it does...how load() function is calling</p> <p>here is the code</p> <pre><code>$("#loadingDiv").show(); var nImages = $("#all-images").length; var loadCounter = 0; $("#all-images img").one("load", function() { loadCounter++; if(nImages == loadCounter) { $(this).parent().show(); $("#loadingDiv").hide(); } }).each(function() { // attempt to defeat cases where load event does not fire // on cached images if(this.complete) $(this).trigger("load"); }); </code></pre> <p>thanks</p>
jquery
[5]
305,563
305,564
Unable to include external jars
<p>I am not able to include include external jars from command line on ubuntu linux while compiling my java program.My external jars are in /home/ubuntu/lib directory Im using this:</p> <p>javac -cp /home/ubuntu/lib c.java</p> <p>but it fails to compile.Can anyone suggest what im doing wrong?</p>
java
[1]
3,121,502
3,121,503
EncodeParameters deinterlace bmp
<p>I'm looking for a way to take in a 32 bit bitmap and save it again however deinterlacing the frames. When the image is taken two fields are visible but only the last one is necessary. Is this possible to do using EncoderParameters. This is what I've tried so far:</p> <pre><code>using (Image source = Image.FromFile(@"C:\Users\Martin vanPutten\Desktop\test.bmp")) { ImageCodecInfo codec = ImageCodecInfo.GetImageEncoders().First(c =&gt; c.MimeType == "image/bmp"); EncoderParameters parameters = new EncoderParameters(3); parameters.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 100L); parameters.Param[1] = new EncoderParameter(System.Drawing.Imaging.Encoder.ScanMethod, (int)EncoderValue.LastFrame); parameters.Param[2] = new EncoderParameter(System.Drawing.Imaging.Encoder.RenderMethod, (int)EncoderValue.RenderNonProgressive); source.Save(@"C:\Users\Martin vanPutten\Desktop\test2.bmp", codec, parameters); } </code></pre> <p>Is there another way to do this? All I need to do is remove the second overlapping frame in an image.</p> <p>Quick update, its not that it has two frames, but 2 fields in 1 frame.</p>
c#
[0]
1,429,425
1,429,426
Compare a dict to itself and remove similar keys efficiently
<p>I would like to compare elements in a dictionary to one another, and remove items according to some comparison criteria. And I'd love it to be efficient. I have a function that can do this, but it repeatedly copies the dictionay. Surely there is a superior way:</p> <pre><code>mydict = {1:5,2:7,3:9,4:9,7:7,8:0,111:43,110:77} def partial_duplicate_destroyer(mydict,tolerance): for key1 in mydict.keys(): mydict_copy = mydict.copy() for key2 in mydict_copy.keys(): if key2 - tolerance &lt; key1 &lt; key2 + tolerance and not(key1 == key2): del(mydict[key1]) break return mydict print partial_duplicate_destroyer(mydict,2) print partial_duplicate_destroyer(mydict,20) print partial_duplicate_destroyer(mydict,200) #correct output: # {4: 9, 8: 0, 111: 43} # {8: 0, 111: 43} # {111: 43} </code></pre>
python
[7]
851,684
851,685
Calling javascript function from objectiveC
<p>I have a function/method in .html file and I need to call that function from objective C code. I have a page with UIWebView and we need to call and pass few parameters to javascript function in .html file. Please let me know if anybody has any answers. Thanks. </p>
iphone
[8]
1,712,492
1,712,493
Handling changing of dispaly orientation android
<p>I`ve locked my display orientation with </p> <pre><code> this.setRequestedOrientation( ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); </code></pre> <p>in my <code>onCreate()</code> method and thats, of course, works fine. Now I want to handle the changing of my display orientation. I want to rotate my ImageView the same way as it`s realized in android camera. Any ideas? thanks a lot</p>
android
[4]
1,081,417
1,081,418
parseInt Alternatives for parsing numerical strings
<p>Assuming I have a numerical string:</p> <pre><code>var foo = "0"; </code></pre> <p>Assume I want to parse it as a number, and increment it assigning the value to <code>bar</code> (just an arithmetical example), I know I could do:</p> <pre><code>var bar = parseInt(foo, 10)+1; </code></pre> <p>But I believe the above example could be simpler and more readable. Consider this example:</p> <pre><code>//alternative 1 var bar = +foo+1; </code></pre> <p>And this one:</p> <pre><code>//alternative 2 var bar = ++foo; </code></pre> <p>Both of these will also yield the same result for <code>bar</code> (the latter will also increment <code>foo</code>, but that's no problem).</p> <p>My question is, by using one of these alternatives, would I be exposing my code to the same possible implementation-dependant flaws of using <a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/parseInt" rel="nofollow"><code>parseInt</code></a> without specifying a <code>radix</code>/<code>base</code>?</p> <p>Or are these safe to use as well?</p> <p><a href="http://jsfiddle.net/ult_combo/q4q4v/" rel="nofollow"><strong>Fiddle for testing</strong></a>.</p>
javascript
[3]
5,833,974
5,833,975
hide view in interface builder when there are multiple views
<p>This is probably a dumb question, but I can't seem to figure it out. In IB, if I have two UIViews, that are subviews of the main UIViewController.view that I basically show and hide depending on the user's input, is there a way to hide one of the views while working in IB. All the text/buttons are on top of each other so I can't really tell what's going on. Is there a way to just make that view and all its children hidden while I work on the other view? Thanks.</p>
iphone
[8]
242,160
242,161
how can i make a textfield that only accepts letters backspace and spacebar only
<p>i need to have a textfield that does not show anything if the user typed special characters or numbers. i have this Name textfield and i need to narrow it to letters input only. the user can also backspace and shift (by using keypress or keytyped or keyrelease whichever be better) </p> <p>EDITED.</p>
java
[1]
5,217,371
5,217,372
Recursive implementation of permutations in Python
<p>I apologize that there have already been many posts about this problem. However, I am having a hard time seeing where I am going wrong in my own implementation. So I am trying to write a function that takes in a string and returns all of it's possible permutations in the form of a list. </p> <p>Theoretically it should look like this: </p> <p>allPermutations("abc...z") = [a + allPermutations(b,c,...z), b + allPermutations(a,c...z)...]</p> <p>My current implementation, when tested on the String, "Hello", outputs a bunch of duplicate permutations. Can anyone help me see where I am going wrong. I appreciate your assistance!</p> <p>Here is the Code:</p> <pre><code>def allPermutations(strng): if len(strng) ==1: return [strng] perm_list = [] for i in strng: smallerStr = strng.replace(i,"",1) z = allPermutations(smallerStr) for t in z: perm_list.append(i+t) return perm_list </code></pre>
python
[7]
285,628
285,629
Fetching data from Internet in background and showing ProgressDialog or ProgressBar
<p>I am developing an application which require accessing a website for data, and will show that data on device. I wants to fetch data from Internet in background and show ProgressDialog or ProgressBar on device and when application receive response from server app will dismiss the dialog or bar and will show data .</p> <p>For this i am using AsyncTask -</p> <p>code for AsyncTask is as follows--</p> <pre><code>ServerTask extends AsyncTask { @Override protected void onPreExecute() { dialogAccessingServer = new ProgressDialog(ctx); dialogAccessingServer.setMessage(shownOnProgressDialog); dialogAccessingSpurstone.show(); } @Override protected ServerResponse doInBackground(String... urlArray) { String urlString = urlArray[0]; HttpResponse serverResponseObject = null; //finding HttpResponse return serverResponseObject; }//end of doInBackground @Override protected void onPostExecute(HttpResponse serverResponseObject){ dialogAccessingSpurstone.dismiss(); } } </code></pre> <p>and calling this code as follows--</p> <pre><code>ServerTask serverTaskObject = new ServerTask(); serverTaskObject.execute(); HttpResponse response = serverTaskObject.get(); </code></pre> <p>//performing operation on response</p> <p>but ProgressDialog is not shown.(I guess the reason for it is the thread is not complete and android invalidate only when thread has completed).</p> <p>My Questions -- 1- If my guess is right ? If yes then how I should implement it? 2- If there is any other better way to do this?</p> <p>thanks </p>
android
[4]
627,181
627,182
ASP.Net Typed Datasets life span
<p>What happens to a dataset when your done using it. For example if I create and fill a dataset for a grid, when the user leaves that page or logs out I assume the dataset is still in memory?</p> <p>Does each user get their own instance of the dataset? In other words, if 2 users hit the same page that uses a grid are they each served their own instance of the dataset from server memory?</p>
asp.net
[9]
503,565
503,566
Sharing data between tabs
<p>I am getting some glitches while making a tab enabled application.<br> I want to share data, between two tabs of my application. How can I achieve the same?</p> <p>Rgds Robert</p>
android
[4]
822,002
822,003
C# - Am I replacing perfectly good code?
<p>I had a quick function to format a date, here it is:</p> <pre><code>public static string archiveServerDateTime(string datetime) { DateTime tempDateTime = DateTime.ParseExact(datetime,"dd.MM.yyyy HH:mm:ss", null); return tempDateTime.ToString("yyyy/MM/dd:HH:mm:ss"); } </code></pre> <p>only to find the output of the function = 2009.10.22:16:21:03, and amazingly this is only on 1 production server, test server worked perfectly fine......</p> <p>So now I rewrote the function to old school style:</p> <pre><code>public static string archiveServerDateTime(string datetime) { DateTime tempDateTime = DateTime.ParseExact(datetime,"dd.MM.yyyy HH:mm:ss", null); string yearPart = Convert.ToString(tempDateTime.Year); string monthPart = Convert.ToString(tempDateTime.Month).PadLeft(2,'0'); string dayPart = Convert.ToString(tempDateTime.Day ).PadLeft(2, '0'); string hourPart = Convert.ToString(tempDateTime.Hour).PadLeft(2, '0'); string minutePart = Convert.ToString(tempDateTime.Minute).PadLeft(2, '0'); string secondPart = Convert.ToString(tempDateTime.Second).PadLeft(2,'0'); return yearPart + @"/" + monthPart + @"/" + dayPart + ":" + hourPart + ":" + minutePart + ":" + secondPart; //return tempDateTime.ToString("yyyy/MM/dd:HH:mm:ss"); } </code></pre> <p>So I ask you ladies and gentlemen, was I replacing perfectly good code to begin with, or is this a Microsoft bug of some kind? Can we really trust these new language features that are seemingly not so rock solid, or am I just missing something?</p>
c#
[0]
5,605,086
5,605,087
Global Variables Bad
<p>Ok after reading this article and also some of the examples I am still not clear on what global variables mean. So its say private variables in your class are global?</p> <p><a href="http://www.c2.com/cgi/wiki?GlobalVariablesAreBad" rel="nofollow">http://www.c2.com/cgi/wiki?GlobalVariablesAreBad</a></p> <p>So can someone explain this to me in simple terms the context. Does this mean even private fields at the top of your class? I'm not clear on the definition of a "global variable" so that I can distinguish if I'm doing something "bad" in my classes.</p>
c#
[0]
2,949,264
2,949,265
volatile vs. mutable in C++
<p>I have a question about the difference between volatile and mutable. I noticed that both of the two means that it could be changed. What else? Are they the same thing? What's the difference? Where are they applicable? Why the two ideas are proposed? How to use them in different way?</p> <p>Thanks a lot. </p>
c++
[6]
775,816
775,817
Making part of the view transparent/overlay while the rest isn't
<p>I'd like to show an overlay view similar to what you see when you perform a 'Search in Contacts app where the SearchBar is visible under the toolbar while the gray overlay covers up all of the content below.</p> <p>For my view, I'd like to have an UITextField and button shown visible while the rest of screen is gray with the rest of the existing contents as grayed-over and no SearchBar.</p> <p>Things I tried:</p> <ol> <li><p>I can have one view that encases both UITextField and button with the view's alpha level set to 0.5. But this yields grayed appearance for everything, including the UITextField and button, which is not what I'm trying to achieve. </p></li> <li><p>I then tried two child views within a parent UIView, with one subview containing the controls while the other one is blank. Set the parent UIView to have 0.5 alpha -> this is not right either.</p></li> <li><p>Continuing with two child views within a parent UIView, set the parent view to have alpha of 1.0 and then the the blank-view to have an alpha level of 0.5, it's still not right.</p></li> </ol> <p>So what's a good way to achieve this?</p>
iphone
[8]
4,374,487
4,374,488
how can I impelement bitblt function in Android
<p>I want to move a part of my screen to left or right in Android like BitBlt function in C++ and C# or a same method by which I can move part of my screen, but I didn't find any thing to do that. Could you help me to move a part of my screen in canvas of OpenGL to left or right side ? Thank you in advance.</p>
android
[4]
2,543,967
2,543,968
Is there any case where len(someObj) does not call someObj's __len__ function?
<p>Is there any case where len(someObj) does not call someObj's <code>__len__</code> function?</p> <p>I recently replaced the former with the latter in a (sucessful) effort to speed up some code. I want to make sure there's not some edge case somewhere where len(someObj) is not the same as someObj.<code>__len__</code>().</p>
python
[7]
4,573,651
4,573,652
unordered_map max_size
<p>I am using <code>std::unordered_map</code> and was trying to get the memory consumption so I did the following:</p> <pre><code>#include &lt;iostream&gt; #include &lt;unordered_map&gt; using namespace std; int main(){ unordered_map&lt;int, int&gt; map; map[21] = 12; cout &lt;&lt; map.size() &lt;&lt; endl &lt;&lt; map.max_size() &lt;&lt; endl; return 0; } </code></pre> <p>to which the result is:</p> <pre><code>1 1152921504606846975 </code></pre> <p>the first one is correct, what the heck is the second one?!</p>
c++
[6]
4,121,709
4,121,710
Javascript .pac file
<p>Is there a way to get a browser to read a .pac file without having the user manually point the browser's automatic config file at the URL?</p>
javascript
[3]
815,285
815,286
simple for loop help needed in php
<p>I have 568 rows in my csv file and my for loop looks like this</p> <pre><code>$csv = array(); $file = fopen('names.csv', 'r'); while (($result = fgetcsv($file)) !== false) { $csv[] = $result; } fclose($file); for ($row = 0; $row &lt; 568; $row++) { echo "Serial no:&lt;br/&gt;"; echo "Name:".$csv[$row][1].""; } </code></pre> <p>I want the output like this...</p> <pre><code>Serial no: 1 Name: Blah blah 1 Serial no: 2 Name: Blah blah 2 ............ ............ Serial no: 10 Name: Blah blah 10 </code></pre> <p>For each 10 rows i want serial 1 to 10.. Once it finished 10 rows i want a horizontal line..</p> <p>I mean i want to print </p> <pre><code>echo "&lt;hr&gt;"; </code></pre> <p>For every 10 rows..</p> <p>Can anyone help me? Thanks</p>
php
[2]
3,554,885
3,554,886
Image With Asp.Net Web Application
<p>I have a problem with Images I have a image which is at root directory like “C:\Mh\mahesh1” and tried to upload by following ways but won’t works.</p> <pre><code>Defaults.aspx.cs namespace UITI { public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { string img = MapPath("~Mh/mahesh1.jpg"); myimages.ImageUrl = img; } } } Defaults.aspx &lt;%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="UITI._Default" %&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml" &gt; &lt;head runat="server"&gt; &lt;title&gt;Untitled Page&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;form id="form1" runat="server"&gt; &lt;div&gt; &lt;asp:Image ID="myimages" runat="server" BorderStyle="Double" /&gt; &lt;/div&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>I have also tried on Default.aspx.cs page like:</p> <pre><code>namespace UITI { public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { string img = ResolveClientUrl ("~/Mh/mahesh1.jpg"); myimages.ImageUrl = img; } } } </code></pre> <p>How to do?.</p>
asp.net
[9]
5,477,177
5,477,178
Toolbar over UIKeyboardTypeNumberPad with a 'Done' Button
<p>Looking to add a toolbar over UIKeyboardTypeNumberPad with a 'Done' Button. Has any one seen a good current tutorial? Is this the correct approach? Thanks. </p>
iphone
[8]
941,900
941,901
Passing object references between modules
<p>I am rather new to javascript and trying to learn some of the best practices. I am unclear as to why I can't access the ctx reference in the following code. The log outputs a context2d reference from myApp.init(). Can I not expose a private object variable in the return statement of the myApp module? I thought I was beginning to understand the basics of this language but am getting frustrated by this seemingly simple concept. Thanks for your help.</p> <pre><code>window.onload = function () { myApp.init(); console.log(myApp.ctx); // logs undefined }; var myApp = (function () { var canvas, ctx, init = function () { canvas = document.getElementById("canvas"); ctx = canvas.getContext('2d'); console.log(ctx); // logs valid context2d object }; return { init : init, ctx : ctx }; }()); myApp.board = (function () { var ctx = myApp.ctx; return { ctx : function () { console.log(ctx); } // logs undefined }; }()); </code></pre>
javascript
[3]
3,587,645
3,587,646
What is the fastest way to find out how many non-empty lines are in a file, using Java?
<p>What is the fastest way to find out how many non-empty lines are in a file, using Java?</p>
java
[1]
4,644,999
4,645,000
ASP.Net circular reference situation
<p>I have the following code and everytime i try to compile, I get the error "/Website/InsightLogo.ascx has a circular reference!" I am assigned to fix up somebody els' code, so please excuse any odd mistakes</p> <pre><code>&lt;%@ Control Language="vb" AutoEventWireup="false" CodeBehind="InsightLogo.ascx.vb" Inherits="eDox.InsightLogo" %&gt; &lt;%@ Register Src="InsightLogo.ascx" TagName="InsightLogo" TagPrefix="uc1" %&gt; &amp;nbsp;&lt;img src="Images/InsightLogo.bmp" alt="Company Logo"/&gt; </code></pre>
asp.net
[9]
800,435
800,436
questions on 0xff
<p>I am working on a C++ code. Not very sure what the code below is trying to do. Would like someone's help on it.</p> <pre><code>int pval = t_gamma[depth[i]]; int lb = pval &amp; 0xff; switch (pval&gt;&gt;8) { case 0: depth_mid[3*i+0] = 255; depth_mid[3*i+1] = 255-lb; depth_mid[3*i+2] = 255-lb; break; case 1: depth_mid[3*i+0] = 255; depth_mid[3*i+1] = lb; depth_mid[3*i+2] = 0; break; case 2: depth_mid[3*i+0] = 255-lb; depth_mid[3*i+1] = 255; depth_mid[3*i+2] = 0; break; case 3: depth_mid[3*i+0] = 0; depth_mid[3*i+1] = 255; depth_mid[3*i+2] = lb; break; case 4: depth_mid[3*i+0] = 0; depth_mid[3*i+1] = 255-lb; depth_mid[3*i+2] = 255; break; case 5: depth_mid[3*i+0] = 0; depth_mid[3*i+1] = 0; depth_mid[3*i+2] = 255-lb; break; default: depth_mid[3*i+0] = 0; depth_mid[3*i+1] = 0; depth_mid[3*i+2] = 0; break; } </code></pre>
c++
[6]
5,701,613
5,701,614
Can we define a delegate inside a method in C#?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/359320/creating-a-delegate-type-inside-a-method">Creating a delegate type inside a method</a> </p> </blockquote> <p>Hi All,</p> <p>Can we define a delegate inside a method in C# ?</p>
c#
[0]
1,960,811
1,960,812
how to retrieve a string in xml parsing?
<p>How to retrieve a string from a web service url using XML Parsing.</p>
iphone
[8]
1,031,796
1,031,797
Fill A Variable Size Array
<pre><code>int* HT; int HTc = 500; HT = new int[HTc] = {-1}; //Fill array with -1 </code></pre> <p>I get the <em>warning</em>: </p> <blockquote> <p>extended initializer lists only available with -std=c++0x or =std=gnu++0x</p> </blockquote> <p>I'll assume this means it isn't compatible with the ANSI standard, which my prof. is nuts for. How else would I do this though?</p>
c++
[6]
1,339,857
1,339,858
How to package an ASP.NET application to prevent customers from modifying it?
<p>Is there a tool or some general approach to packaging all the files of an ASP.NET application into binary form to prevent modification once its deployed? I am thinking there would be a set of signed binaries and a config file for settings that we allow the customer to modify. Has anyone attempted this, is it even possible?</p> <p>I would pay a reasonable amount for a slick commercial product that did this with minimal hassle.</p> <p><strong>UPDATE</strong></p> <p>Sorry, from the answers I can see that I wasn't clear. I meant literally packaging ALL files, not just the code files. This means aspx, scripts, images etc. I'm not trying to prevent reverse engineering... this is a supportability issue, i.e. to avoid dealing with problems brought about by customer messing with the files.</p>
asp.net
[9]
5,109,803
5,109,804
HTML Output from XML and strange characters
<p>Im using CURL to fetch Twitter RSS, then write those tweets to Wordpress.</p> <p>Here is an example of the XML:</p> <pre><code> &lt;title&gt;Bob: Twitter&amp;#8217;s @Anywhere Platform Is Now Live - http://bit.ly/b54cTS&lt;/title&gt; </code></pre> <p>I then write this to Wordpress, but the result is:</p> <pre><code>Bob: Twitterâs @Anywhere Platform Is Now Live - &lt;a href="http://bit.ly/b54cTS" target="_blank"&gt;http://bit.ly/b54cTS&lt;/a&gt; </code></pre> <p>Not the <code>âs</code> character, can any suggest what I might be doing wrong?</p>
php
[2]
5,320,047
5,320,048
How to add two map tangs in single xml file in Android
<p>I am creating tab bar in my application. For one tab i set map activity as tab spec content and add overlay on it. now i have to move on next map as user clicks on overlay. In short I have to create two layouts each on has map and at run time i have to set visibility and one after other. For that i create one XML layout which has linear layout as root layout and then create two separate relative layouts to hold two maps but it gives me error that unexpectedly closed.</p> <p>If you know another way to do it please suggest me. Thank You VIkram Kadam</p>
android
[4]
2,108,878
2,108,879
Importing modules with variable paths?
<p>I have dev and production systems.</p> <p>My production system is different from my dev system in that that it adds one directory to the beginning path.</p> <p>for eg. on dev system:</p> <p>main->module1->module2</p> <p>becomes on production:</p> <p>project_name->main->module1->module2.</p> <p>Because of that I have to change all my imports to accommodate for this change.</p> <p>I wanted to make settings file in the main folder and include it in every file and call exec("import %s.modulexxx" % path).</p> <p>But the problem is how to access settings file (because I also need to know my directory path).</p> <p>Is there a way to include some file below, for eg. :</p> <p>if it is main->module1->module2 , in module2 I could include ../../settings.py so if it changes to project_name->main->module1->module2 it would still work because it would still be 2 level below.</p> <p>Any help?</p>
python
[7]
4,850,723
4,850,724
Find if first character in a string is upper case, Java
<p>In java, Find if first character in a string is upper case without using regular expression.</p>
java
[1]
5,471,414
5,471,415
formate date in javascript
<pre><code>var mydate = new Date(); var theyear = mydate.getFullYear(); var themonth = mydate.getMonth() + 1; var thetoday = mydate.getDate(); txtbox.value="04-Jul-2012" </code></pre> <p>I have to convert todays date and txtbox date in "04/07/2012" format how i do it.</p> <p>I have to compare todays date with txtbox date.</p> <p>Thanks</p>
javascript
[3]
2,634,847
2,634,848
Get the folder path under cursor?
<p>I'am working on my small project: Crypt container. To unlock it - just plug-in specifig usb flash-drive and unplug it to lock container. </p> <p>So, GUI of program is very simple - just ListView. If you want to add files into continer - drag'n'drop items to them.</p> <p>But i have a problem - when user want to decrypt his file, he drag them in container and drop to desktop (or specific folder). And my task is to know, where user wants to put a file. If he drag file to folder - i should unpack it to folder, if he drag it to flash-drive - i should unpuck it to flash-drive.</p> <p>Yes, i found one solution of my problem: <a href="http://www.codeproject.com/KB/files/DragNDrop.aspx" rel="nofollow">http://www.codeproject.com/KB/files/DragNDrop.aspx</a> , but i realy not understand that mechanism with tempDirectoryWatcher and Hashtables. </p> <p>Maybe somebody know easy way to get path to object (folder, drive, etc.) under cursor?</p>
c#
[0]
4,654,977
4,654,978
Define "custom" integer-based type?
<p>I have a program that is interfacing with an external library that, among other things, has an unsigned 12-bit value packed in a larger struct.</p> <p>This used to be 8 bits, so we simply marshaled it as a byte.</p> <p>Now that it's 12 bits... I can use a ushort, but that opens up issues of (a) range checking and (b) marshaling.</p> <p>Is there a simple way of implementing a constrained numeric type like this, where I don't have to override every assignment and comparison method?</p>
c#
[0]
5,734,672
5,734,673
jQuery's if $('#foo').is(':hidden') and $('#foo').slideUp() not working when "display: none !important"?
<p>This one works: </p> <blockquote> <p><a href="http://jsfiddle.net/fGnL7/3/" rel="nofollow">http://jsfiddle.net/fGnL7/3/</a> </p> </blockquote> <p>using</p> <pre><code>$(document.body).click(function () { if ($("div:first").is(":hidden")) { $("div").slideDown("slow"); } else { $("div").slideUp("slow"); } }); </code></pre> <p>but if for some reason, the element is made <code>display: block</code> by some framework (by Compass/Blueprint's <code>+clearfix</code>), so I used </p> <pre><code>display: none !important </code></pre> <p>to make it not show on page at first, and then the code will not work.</p> <blockquote> <p>sample: <a href="http://jsfiddle.net/fGnL7/4/" rel="nofollow">http://jsfiddle.net/fGnL7/4/</a></p> </blockquote> <p>I also tried adding <code>$("div").css({display: 'block'});</code> or even <code>$("div").css({display: 'block !important'});</code> before it called <code>slideDown()</code> and it doesn't work either. </p> <blockquote> <p>sample: <a href="http://jsfiddle.net/fGnL7/7/" rel="nofollow">http://jsfiddle.net/fGnL7/7/</a></p> </blockquote> <p>Is there a way around this?</p>
jquery
[5]
1,484,227
1,484,228
Generate start and ending datetimes in UTC based on a PST date
<p>I am taking in a parameter that is a date in PST timezone which will be in the format of "YYYY-MM-DD" (e.g. "2011-08-15"). This parameter is optional. I have 2 questions that I've been struggling with.</p> <p>I need to calculate the start and end datetime in <strong>UTC</strong> for this date.</p> <p>So if the inputted date is <code>2011-08-15</code>, I want to get the start and end datetimes:</p> <p><code>2011-08-15 07:00:00</code></p> <p><code>2011-08-15 06:59:59</code></p> <p>(These are essentially the beginning and end of day)</p> <p>Second, is to handle the case when the date is not passed in. I want to default to the current PST date them and start from there. So if the current datetime is <code>2011-08-01 10:00:00</code>, I want to get the same start and end datetimes similar to the first scenario except it's based on the inputted date.</p> <p><code>2011-08-01 07:00:00</code></p> <p><code>2011-08-01 06:59:59</code></p> <p>I've been pulling my hair out dealing with date and datetime conversions. I'm sure I'm missing something super straightforward.</p>
php
[2]
5,438,988
5,438,989
Custom HttpHandler never running
<p>Forgive me if this is basic. I've never made one before and can't seem to figure out why it's not working. I wrote a little handler to do some parsing on CSS files. I added this:</p> <pre><code> &lt;system.web&gt; &lt;httpHandlers&gt; &lt;remove verb="*" path="*.css"/&gt; &lt;add verb="*" path="*.css" type="MyNameSpace.CssRelativePathHandler,CssRelativePathHandler" /&gt; &lt;/httpHandlers&gt; &lt;/system.web&gt; </code></pre> <p>Nothing ever happens. CSS files get parsed normally. No errors, nothing, the code never runs. What am I missing? Shouldn't this cause the handler to be used when *.css files are served? (I added the "remove" later, since I thought perhaps I needed to do that to override a built-in hander, again, no difference either way).</p> <p>This is IIS 6. I added the IIS 7 code anyway (after searching for answers) but makes no difference.</p> <pre><code> &lt;system.webServer&gt; &lt;handlers&gt; &lt;add name="CssHandler" verb="*" path="*.css" type="MyNameSpace.CssRelativePathHandler,CssRelativePathHandler" /&gt; &lt;/handlers&gt; &lt;/system.webServer&gt; </code></pre>
asp.net
[9]
5,185,687
5,185,688
Pointer to member variable
<p>The following program output is always 1 1 1. In "Inside the c++ object model" book, it is mentioned that it will give offset. The purpose is also to find out object layout. But, I am confused with the output. Used g++ 4.5.2 </p> <pre><code>class Test { public: float a; float b; float c; }; int main() { float Test::*ptr = &amp;Test::a; float Test::*ptr1 = &amp;Test::b; float Test::*ptr2 = &amp;Test::c; cout&lt;&lt;ptr&lt;&lt;endl; cout&lt;&lt;ptr1&lt;&lt;endl; cout&lt;&lt;ptr2&lt;&lt;endl; return 0; } </code></pre> <p>Output:</p> <pre><code>1 1 1 </code></pre> <p>Edit(Follow up question): In the book it is mentioned that <code>origin.y = 0</code> can be transformed to <code>&amp;origin + (Point3d::y-1)</code> where origin is an object to Point3d and y is member variable of class Point3d. Though When I compiled it gave me compilation error.</p>
c++
[6]
2,104,084
2,104,085
How to confirm only html files exist in a given folder and if not then how to prompt the user to specify a folder with only html files within
<p>I would like to create a python script that will do 3 things: <li>1) Take user input to navigate to a file directory</li><li>2) Confirm the file contents (a particular set of files need to be in the folder for the script to proceed)</li><li>3) Do a Find and Replace</li></p> <p>The Code as of now: </p> <pre><code>import os, time from os.path import walk mydictionary = {"&lt;/i&gt;":"&lt;/em&gt;"} for (path, dirs, files) in os.walk(raw_input('Copy and Paste Course Directory Here: ')): for f in files: if f.endswith('.html'): filepath = os.path.join(path,f) s = open(filepath).read() for k, v in mydictionary.iteritems(): terms for a dictionary file and replace s = s.replace(k, v) f = open(filepath, 'w') f.write(s) f.close() </code></pre> <p>Now i Have parts 1 and 3, I just need part 2.</p> <p>for part 2 though I need to confirm that only html files exist in the directory the the user will specified otherwise the script will prompt the user to enter the correct folder directory (which will contain html files)</p> <p>Thanks </p>
python
[7]
6,006,641
6,006,642
Using .join() in Python
<p>Very simple and quick question. Take this list for example: </p> <pre><code>a = ['hello1', 'hello2', 'hello3'] ','.join(a) </code></pre> <p>I would like to have 'and' instead of a comma before the last element of the list. So I would get:</p> <blockquote> <p>hello 1, hello 2 and hello 3</p> </blockquote> <p>instead of....</p> <blockquote> <p>hello 1, hello 2, hello 3</p> </blockquote> <p>Is there a way to accomplish this using <code>.join()</code>? I know I can just type it in the list for a simple example like this, but the list I need in my actual program comes from user input.</p>
python
[7]
2,727,462
2,727,463
C# Letter Count
<p>Hi I have a variable <code>'test'</code> string I need to know how many times they were placed in the variable text <code>"&lt;title&gt;"</code></p> <p>thanks</p>
c#
[0]
67,051
67,052
Android way to use Bitmaps from Camera.setPreviewCallback
<pre><code>camera.setPreviewCallback(new Camera.PreviewCallback() { private long timestamp=0; public synchronized void onPreviewFrame(byte[] data, Camera camera) { Log.e("CameraTest","Time Gap = "+(System.currentTimeMillis()-timestamp)); timestamp=System.currentTimeMillis(); Bitmap mFaceBitmap = BitmapFactory.decodeByteArray(data, 0, data.length); if (mFaceBitmap!=null) FaceDetection.calculate(mFaceBitmap); camera.addCallbackBuffer(data); return; } }); </code></pre> <p>I have a camera View, and in front of a simple View (where I can draw something). I'd like to draw on the front of View, when I can find the face of a human. But <code>mFaceBitmap</code> is ever and ever return null, why? </p> <p>If this is a bad idea, how can I do this better?</p>
android
[4]
3,692,246
3,692,247
Unsure about these operators being used in this way
<p>This code example comes from <a href="http://www.cplusplus.com/doc/tutorial/templates/" rel="nofollow">http://www.cplusplus.com/doc/tutorial/templates/</a> :</p> <pre><code>template &lt;class myType&gt; myType GetMax (myType a, myType b) { return (a&gt;b?a:b); } </code></pre> <p>What I am confused about is the "a>b?a:b" section part of the code which is being returned. Can somebody help me to understand what is going on here? Thanks.</p>
c++
[6]
2,766,221
2,766,222
Step through all children and remove all styles
<p>I have a sharepoint site that is driving me crazy trying to remove all the junk code so I can apply my design. I am curious if jquery could strip out all css from all elements inside the containing div?</p> <p>For example, how could I strip all css formatting from this html using jquery?</p> <pre><code>&lt;div id="myID" &gt; &lt;span class="myClass1"&gt; &lt;span class="myClass2"&gt;&lt;/span&gt; &lt;/span&gt; &lt;span class="myClass3"&gt; &lt;ul class="myClass4" style="padding-left:100px;"&gt; &lt;li&gt;item&lt;/li&gt; &lt;/ul&gt; &lt;/span&gt; &lt;/div&gt; </code></pre>
jquery
[5]
1,334,060
1,334,061
New Google Plus Navigation?
<p>Any ideas on how the new navigation in Google Plus is coded (where you hit the "&lt; HOME" button and it pops out a list of activities ("Stream", "Profile", "Messenger", etc)).</p> <p>I initially have been thinking it is a PopupWindow...</p> <p>Thoughts?</p>
android
[4]
3,112,943
3,112,944
Python 2.7 syntax error
<p>I'm new in Python. Does anyone know why there is syntax error as below? </p> <pre><code>self.update( { (u,v) : t for (u,v),t in old_items if u in new_vert and v in new_vert } ) ^ SyntaxError: invalid syntax </code></pre> <p>Thank you. :)</p>
python
[7]
3,762,530
3,762,531
jQuery return false weird behavior
<p>I have a piece of jQuery code that toggles a description paragraph for a given td when users click on an anchor tag, see code below. My problem is that if I put the return false statement as shown, the code works fine in IE but in FF it would not show the description at all, which is expected. When I put the return false after the toggling it works fine in FF but in IE it would show the description and then hides it right away. Is there any way to get it to work properly in both??</p> <p>Thanks in advance.</p> <pre><code>$(".name").click(function(){ return false; $(this).parent() .parent() .find(".description") .animate({ opacity: "toggle", "slow"); }); </code></pre>
jquery
[5]
3,899,997
3,899,998
PHP Strict standards: Creating default object from empty value - How to Fix?
<p>All,</p> <p>I have the following PHP5 code. </p> <pre><code>$request = NULL; $request-&gt;{"header"}-&gt;{"sessionid"} = $_SESSION['testSession']; $request-&gt;{"header"}-&gt;{"type"} = "request"; </code></pre> <p>It appears that line 2 and 3 are producing the following error:</p> <pre><code>PHP Strict standards: Creating default object from empty value </code></pre> <p>How can I fix this error?</p> <p>Thanks</p>
php
[2]
2,818,116
2,818,117
jQuery modal stack with ajax forms
<p>I have a simple function that opens a url inside a modal and there can be multiple modals on the page. In one such example the user would open up a modal from another modal say to edit some content that is currently being show in the first modal.</p> <p>The problem is when the form inside the second modal is submitted (using ajax) is how to refresh the first modal. I would need to know two things which modal to refresh and what content to use to refresh the modal with.</p> <p>Has anyone ever done anything like this before? Has some ideas?</p> <p>The only idea I could come up with was to record the indexes and urls each time a user clicks an ajax modal link and store them in an array and then when the form submits check if the parent modal of the form index matches one of the arrays and then use the values to refresh the correct modal with the url that is also stored inside the array. But this is very long-winded and quite sloppy and the results are unpredictable.</p> <p>Anyone got any other/better solutions?</p> <p>Cheers</p>
jquery
[5]
1,442,392
1,442,393
My script is renaming uploads randomly
<p>The script I have should upload the file, resize and rename with the appropriate size. It is doing that, but instead of renaming the with only the last part it renames it with a temp name only. Here is the script, any help would be greatly appreciated. I have uploaded the script <a href="http://www.filefactory.com/file/cbc8a99/n/class-form.php" rel="nofollow">here</a>:</p>
php
[2]
2,851,109
2,851,110
jquery attr not working in ie8
<p>Can someone help me figure out why the code here is not working? I am pretty sure it has something to do with the .attr: <a href="http://jsfiddle.net/nBcrY/1/" rel="nofollow">http://jsfiddle.net/nBcrY/1/</a></p>
jquery
[5]
5,443,287
5,443,288
How do you check for end of line in c++?
<p>I have to accept space separated integers from user but stop when i encounter a new line. For example: </p> <pre><code>3 5 7 9 23 47 6 </code></pre> <p>In this example I must store <code>3, 5, 7, 9</code> in array 1, <code>23, 47</code> in array 2, <code>6</code> in array 3. Unfortunately, I don't know how to check for the end of line in C++. Please help me out. </p>
c++
[6]
5,702,817
5,702,818
to return an html result in loop in a function to a different page
<p>I have a class</p> <pre><code>class files{ function displayhtml(){?&gt; select name="df"&gt; for($i=0;$i&lt;10;$i++){?&gt; &lt;option value="&lt;?php echo "$i"; ?&gt;"&gt;&lt;?php echo "$i"; ?&gt;&lt;/option&gt;&lt;?php }?&gt;&lt;/select&gt;&lt;?php } } ?&gt; </code></pre> <p>I have a file newgetfile.php, i need to display this drop down in newgetfile.php by calling this function in newgetfile.php</p>
php
[2]
1,364,192
1,364,193
Is there a way to send app statistics to play console?
<p>I know that when app crashes a bug report is sent to my developer console. Now I'd like to add a statistics usage function: for example each week app gathers my app's preferences settings and send them to my dev console. This way I could see what users like more and, on the other hand, what has to be improved. </p> <p>Is it possible with some android function? I know I could do something like send an email, or make an hidden connection to my server but I'd like a more "standard" way (moreover these hidden methods could not be liked by some user)...moreover error logs are sent so there IS a mechanism, problem is if I can attach to it or not</p>
android
[4]
693,332
693,333
Disable "history.go(-1)" on certain pages
<p>I want to be able to disable "history.go(-1)" on certain pages. I'm thinking if is there a way to clean up the Javascript's history object. Ideas? "history.go()" seen to be not functioning too well on certain browsers such as IE. Is that true? Any solution for that?</p>
javascript
[3]
5,811,909
5,811,910
Visual Studio.NET like property window in ASP.NET
<p>Looking for a VS.NET like property window that can be embedded in ASP.NET page, which will allow users to change decorated proerties of a class.</p> <p>any guidance is much appreciated</p> <p>thanks</p>
asp.net
[9]
1,203,823
1,203,824
C# ThreadPool context switch logic
<p>I've been testing out some code that uses <code>ThreadPool</code> in C# and I noticed that a lot of unnecessary context switch occurs. While one thread is executing regular statements it gets context switched. They literally seem to be going back and forth for every line. I was wondering what the logic behind this was. Why would a thread get switched out for regular executions? </p>
c#
[0]
1,612,371
1,612,372
Error when using str_replace() convert from ' to "
<pre><code>&lt;?php $str='&lt;p style="text-align: center;"&gt; &lt;img style="width: 448px; height: 321px;" src="http://admin.vn/images/images/car_1.jpg" alt=""&gt; &lt;/p&gt;'; $search='"'; $replace='''; $string= str_replace($search,$replace,$str); echo $string; ?&gt; </code></pre> <p>When I echo $string is result no convert from " to ' , how to fix it</p>
php
[2]
925,019
925,020
how to use fobs4jmf.jar for both mac and windows
<p>i am using jdk1.6 and in the Apllicatoin i have included fobs4jmf.jar(57kb) for playing videos on windows and for mac fobs4jmf.jar(78kb) they are working properly but i want to make a final jar of the application which will use windows jar for windows and mac jar foe mac dynamically how it is possible</p>
java
[1]
5,678,494
5,678,495
How to send All objects of Mutable Array to Another Class?
<p>I want to send Mutable Array with all its objects from my First Class to Second Class. I have no idea how can i do this please anybody tell me the way... </p>
iphone
[8]
2,933,021
2,933,022
How to resize bbcode linked image to fix within the current div height and width?
<p>Hi I have a comment posting function where public user can link and display images using </p> <p>Something like [img]http://www.google.com/img.png[/img]</p> <p>Issue is that user may link to an image that is of extremely large height and width which is more than the height and width of the div it is in causing some overflow layout issues</p> <p>Is there anyway I can resize the image such that it still fit in the div without losing the aspect ratio?</p> <p>Alternatively can I use CSS something like set overflow to display scroll bar if that happens?</p>
javascript
[3]
32,057
32,058
How to update session.setAttribute(name,value) value, where the is same?
<p>I have a situation where I need to update the value of a setAttribute where the name remains same. Consider the following situation as example-<br/>Suppose I have three JSP: abc.jsp, xyz.jsp, pqr.jsp. Now at first abc.jsp runs then control forward to xyz.jsp &amp; then forward to pqr.jsp. Now after execute pqr.jspthe control back to xyz.jsp again with a updated value at setAttribute.<br/> <strong>abc.jsp:</strong><br/></p> <pre><code>ArrayList&lt;Books&gt; getSupplyStatus=new ArrayList&lt;Books&gt;(); JavaBean javaBean=new JavaBean(); session=request.getSession(false); getSupplyStatus=javaBean.getSupplyStatus(memberID); //It returns a ArrayList if(!getSupplyStatus.isEmpty()) { session.setAttribute("UpdatedBooklist", getSupplyStatus); request.getRequestDispatcher("xyz.jsp").forward(request, response); } </code></pre> <p><strong>xyz.jsp:</strong><br/></p> <pre><code>session=request.getSession(false); ArrayList&lt;Books&gt; getSupplyStatus=(ArrayList&lt;Books&gt;) session.getAttribute("UpdatedBooklist"); // some operations &amp; forward to pqr.jsp </code></pre> <p><strong>pqr.jsp:</strong><br/></p> <pre><code>// in this jsp new ArrayList&lt;Books&gt; will be prodeuced // &amp; I need to bound the value of "UpdatedBooklist" with // which is set in abc.jsp, // and previous value must be override &amp; then forward to xyz.jsp again // In xyz.jsp we recieve the updated value. </code></pre>
java
[1]