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 |
---|---|---|---|---|---|
4,796,692 | 4,796,693 | PHP memory_limit locked to 256MB? | <p>I am trying to set memory_limit to 512M, but it's locekd to 256M.</p>
<pre><code>ini_set('memory_limit','512M');
ini_get('memory_limit'); //> Returns: 256M
</code></pre>
<p>I have full control on my server. (it's a dedicated)</p>
<p>Please note that everything under 512M works.</p>
<pre><code>ini_set('memory_limit','16M');
ini_get('memory_limit'); //> Returns: 16M
</code></pre>
<h2>Solution</h2>
<p>I found out why. in php.ini I had <code>memory_limit = 256M</code>. Maybe this is considered as an upper limit</p>
| php | [2] |
965,079 | 965,080 | Succesive calls to cProfile/pstats no updating properly | <p>I'm trying to make successive calls of some profiler code however on the second call to the function the update time of the profile file changes but the actual profiler stats stay the same. This isn't the code I'm running but it's as simplified an example I can come up with that shows the same behaviour.</p>
<p>On running, the first time ctrl+c is pressed it shows stats, second time same thing but rather than being fully updated as expected only the time is, and third time program actually quits. If trying, ideally wait at a few seconds between ctrl+c presses.</p>
<p>Adding profiler.enable() after the 8th lines does give full updates between calls however it adds a lot of extra profiler data for things I don't want to be profiling.</p>
<p>Any suggestions for a happy medium where I get full updates but without the extra fluff?</p>
<pre><code>import signal, sys, time, cProfile, pstats
call = 0
def sigint_handler(signal, frame):
global call
if call < 2:
profiler.dump_stats("profile.prof")
stats = pstats.Stats("profile.prof")
stats.strip_dirs().sort_stats('cumulative').print_stats()
call += 1
else:
sys.exit()
def wait():
time.sleep(1)
def main_io_loop():
signal.signal(signal.SIGINT, sigint_handler)
while 1:
wait()
profiler = cProfile.Profile()
profiler.runctx("main_io_loop()", globals(), locals())
</code></pre>
| python | [7] |
5,327,257 | 5,327,258 | language localization in xib/ib does not work | <p>I am working on the localization of one of my project.
The function NSLocalizedString in XCode does work.
But when I switch the language setting, it look likes the app does not switch to relevant fr/en/jp file of mainwindow.xib, help.html etc.</p>
<p>Welcome any comment</p>
| iphone | [8] |
1,380,716 | 1,380,717 | How to add my app into the google local search? | <p>In the android we can see that there is a default "google search" on the launcher. And I found out that using setting, we can set the searchable items. For example amazon kindle, music, or browser. </p>
<p>The question is, how can I add my app into the searchable items in the google search? Are there any APIs I can use? </p>
| android | [4] |
174,228 | 174,229 | Multiple jQuery scripts don't work at a same page | <p>I'm a php developer, but sometimes I use jQuery (ready made codes). This time I'm having a problem while running multiple jquery functions. If I remove any one of the jQuery functions (total code feature) then other one works fine, but I need both of these.</p>
<p><a href="http://www.kidsartvalley.com/kidsartvalley/account-setting-gallery2.html" rel="nofollow">http://www.kidsartvalley.com/kidsartvalley/account-setting-gallery2.html</a></p>
<p>See the address above for an example of what I'm talking about. Kindly don't pay attention to the design of the page. That's a different issue, but will be resolved.</p>
<p>The one jQuery function is "album viewer" and the other one is "POST YOUR PHOTOS" at the right corner of page above the heading of gallery.</p>
| jquery | [5] |
5,750,024 | 5,750,025 | Can I select elements with a set of attribute values? | <p>Is there a way to refactor something like this:</p>
<pre><code>$("input[name='InputName1'],input[name='InputName2']").val("");
</code></pre>
<p>into something like this:</p>
<pre><code>$("input[name='InputName1|InputName2']").val("");
</code></pre>
<p>Essentially, is it possible to select elements based on a set of attribute values without the repetitive parts of the selector?</p>
| jquery | [5] |
1,051,069 | 1,051,070 | "using" namespace equivalent in ASP.NET markup | <p>When I'm working with DataBound controls in ASP.NET 2.0 such as a Repeater, I know the fastest way to retrieve a property of a bound object (instead of using Reflection with the Eval() function) is to cast the DataItem object to the type it is and then use that object natively, like the following:</p>
<pre><code><%#((MyType)Container.DataItem).PropertyOfMyType%>
</code></pre>
<p>The problem is, if this type is in a namespace (which is the case 99.99% of the time) then this single statement because a lot longer due to the fact that the ASP page has no concept of class scope so all of my types need to be fully qualified.</p>
<pre><code><%#((RootNamespace.SubNamespace1.SubNamspace2.SubNamespace3.MyType)Container.DataItem).PropertyOfMyType%>
</code></pre>
<p>Is there any kind of "using" directive or some equivalent I could place somewhere in an ASP.NET page so I don't need to use the full namespace every time?</p>
| asp.net | [9] |
1,999,238 | 1,999,239 | Preventing stack overflows in C++ using arrays? | <p>If we implement a stack using arrays in C++, what is the best way to reduce the chance of an overflow condition? Also while keeping in mind the time-space trade off?</p>
| c++ | [6] |
4,076,259 | 4,076,260 | Understanding the process of initialization | <p>This is my attempt to understand how class initialization works. I'm not sure about everything, and that is why I'm asking this question. This is what I believe happens when we do the following:</p>
<pre><code>T t = u;
</code></pre>
<ol>
<li><p>Constructs an object of type <code>T</code> from <code>u</code>. This then becomes:</p>
<pre><code>T t = T(u);
</code></pre></li>
<li><p>Calls the copy-constructor:</p>
<pre><code>T t( T(u) );
</code></pre></li>
</ol>
<p>Okay the second is the part I'm not understanding. I read somewhere that <code>T t = u</code> is made into <code>T t(T(u))</code>. But if that is true why doesn't this print "copy-constructor":</p>
<pre><code>struct T
{
template <class U>
T(U) {
std::cout << "constructs an object of type T...\n";
}
T(T const &)
{
std::cout << "copy-constructor";
}
T& operator=(T const &)
{
std::cout << "assignment operator"; return *this;
}
T() = default;
};
int main()
{
T t(T(5));
}
</code></pre>
<p>Actually, all this does is print "constructs an object of type T". Why isn't the copy-constructor called here? <code>T(5)</code> can be made into an object of type <code>T const &</code> which is passed into the constructor of <code>T</code> so shouldn't the appropriate constructor be called.</p>
<p>I'd really like some insight to this. I've been trying to understand this for a while.</p>
| c++ | [6] |
2,197,005 | 2,197,006 | I don't understand the usefulness of parameter arrays? | <p>Parameter arrays allow a variable number of arguments to be passed into a method:</p>
<pre><code> static void Method(params int[] array)
{}
</code></pre>
<p>But I fail to see their usefulness, since same result could be achieved by specifying a parameter of particular array type:</p>
<pre><code> static void Method(int[] array)
{}
</code></pre>
<p>So what benefits ( if any ) does parameter array have over value parameter of array type? </p>
<p>thank you</p>
| c# | [0] |
647,726 | 647,727 | PHP Check existance of record in the database before insertion | <p>I have code that is supposed to check if records exists on the database before insertion and if records exists, does not insert but my code does not prevent that but instead it inserts. </p>
| php | [2] |
4,727,194 | 4,727,195 | jquery stop executing after callback function | <p>I have a simple plugin, used for submitting form</p>
<pre><code>(function($){
$.fn.ajaxSubmit = function(options){
var defaults = {
onSubmit:function(){},
},
o = $.extend({},defaults, options);
return this.each(function(){
$(this).submit(function(e){
o.onSubmit.call(this);
$.post(o.url,$(this).serialize() ,
function(i){"do stuff"},'json');
return false;
});
});
}
})(jQuery);
</code></pre>
<p>And this is how I call it</p>
<pre><code>$('#commentForm').ajaxSubmit({
onSubmit:function(){
if($('textarea').val()==''){ "do not execute $.post"}
}
});
</code></pre>
<p>I want to check if textarea is empty, if it is, do not proceed further down the plugin or do not execute the $.post.</p>
| jquery | [5] |
1,611,985 | 1,611,986 | sqlite with android no such table | <p>I have been testing my app which uses the dbadapter from Reto Meir's earthquake example. Everything was going ok for several days but when debugging with the app on the device today I got the 'no such table' error. I changed the name of the database and all runs well again. This doesn't give me much confidence regarding potential other users.</p>
<p>Since it seems impossible to see the database on the phone, by design I suppose, I can't see how to find out what caused the problem and take steps to avoid it. The database appears to open ok at the start of the program but errors when handling a select query. Just changing the name of the table doesn't fix it, it has to be a new database name.</p>
<p>As the change of name allows it to run ok I can't see that the code is wrong. I wonder if the data becomes corrupted.</p>
<p>I've also found that after successfully inserting a row, then later getting a cursor to allitems sometimes produces a -1 error against a get for one of the column names. How can a column name drop out of the columns index?</p>
<p>I've googled this type of problem and whilst there are a lot of folks with the problem and a lot of replies I can't find anything which informs on the underlying reason for these problems - which is what I am after. </p>
| android | [4] |
79,165 | 79,166 | ASP.NET: concept question regarding variable declaration | <p>consider this code: </p>
<pre><code>Partial Public Class MyAspNETClass
Inherits System.Web.UI.Page
Protected Shared MyVariable As String
....
....
</code></pre>
<p>2 questions: </p>
<ol>
<li>Is Myvariable a variable used local
for each instance of the page ? Or
that variable is "shared" for all
users accessing my page ?</li>
<li>Is MyVariable saved in server
memory, or is it saved on the
viewstate of aspx page ?</li>
</ol>
<p>This is 2 doubt i can't answering by myself, so i'm asking you !
Thanks</p>
| asp.net | [9] |
5,375,418 | 5,375,419 | Pass the return type as a parameter in java? | <p>I have some files that contain logs of objects. Each file can store objects of a different type, but a single file is homogeneous -- it only stores objects of a single type.</p>
<p>I would like to write a method that returns an array of these objects, and have the array be of a specified type (the type of objects in a file is known and can be passed as a parameter).</p>
<p>Roughly, what I want is something like the following:</p>
<pre><code>public static <T> T[] parseLog(File log, Class<T> cls) throws Exception {
ArrayList<T> objList = new ArrayList<T>();
FileInputStream fis = new FileInputStream(log);
ObjectInputStream in = new ObjectInputStream(fis);
try {
Object obj;
while (!((obj = in.readObject()) instanceof EOFObject)) {
T tobj = (T) obj;
objList.add(tobj);
}
} finally {
in.close();
}
return objList.toArray(new T[0]);
}
</code></pre>
<p>The above code doesn't compile (there's an error on the return statement, and a warning on the cast), but it should give you the idea of what I'm trying to do. Any suggestions for the best way to do this?</p>
| java | [1] |
793,084 | 793,085 | How to make a C++ program interact with mouse clicks and X Window System application? | <p>How do I exactly make a C++ program interact with another program and interact with something I have clicked on.</p>
<p>Example: If I wanted to make an MSN auto reply program and I would have a dialog box that would ask me what I would want to type and than the program would paste that into the MSN chat box.</p>
| c++ | [6] |
3,314,394 | 3,314,395 | How do I pass a ref string to my method? | <p>I have the following sniplet of a stored procedure in SQL Server</p>
<pre><code> Create PROCEDURE [dbo].[usp_Genpwd]
@pass varchar(8) OUTPUT
AS
BEGIN
</code></pre>
<p>In my c# code, how do I get the output from the stored proc throught the data context? </p>
<pre><code> var pwd = db.usp_Genpwd(..)
</code></pre>
<p>Intellisense says to put ref string pass in the paranthesis but when I do the following:</p>
<pre><code> var pwd = db.usp_Genpwd(ref string pass);
</code></pre>
<p>I get a invalid arguments error</p>
<p>I am not sure what goes in the paranthesis as I am outputting a value from the stored proc.</p>
| c# | [0] |
2,431,794 | 2,431,795 | PHP for each loop error | <p>I have a loop to go through an array and each <code>checkbox</code> that is selected I want to put the value (also brought in dynamically) into my <code>QuestionSelected</code> table. I get this error <code>"Warning: Invalid argument supplied for foreach()"</code> and I cannot get the results into my table. Here is the code I am trying:</p>
<pre><code>//Declare the QuestionID as a array
$QuestionID = array();
while($row = mysqli_fetch_array($run,MYSQLI_ASSOC)){
echo '<div id="QuestionSelection"><input id="chkQuestion" type="checkbox" value=" '.$row['QuestionID'].'" name="question_'.$row['QuestionID'].'">' .$row['Question']. '</p></div><br/><br/>';
//Assign the QuestionID from the table to the var
$QuestionID[] = $row['QuestionID'];
}
if($_POST['submitted']) {
$ids_list = '';
foreach($_POST["QuestionID"] as $id)
{
$ids_list .= (strlen($ids_list) > 0 ? ',' : '').mysql_real_escape_string($id);
}
$sql2 = "INSERT INTO tbl_QuestionSelected (`QuestionID`) VALUES (".$ids_list.")";
}//End of IF 'submitted
</code></pre>
| php | [2] |
556,141 | 556,142 | Is this matching from Scala is available in C#? | <p>I found nice little one example of Scala today. Something like:</p>
<pre><code>(1 to 100) map { x =>
(x % 2, x % 6) match {
case (0,0) => "First"
case (0,_) => "Second"
case (_,0) => "Third"
case _ => x toString
}
} foreach println
</code></pre>
<p>And i wonder if I could do something similar in C#. I tried to search on my own but it's hard since I don't know name of this expression. It seems pretty useful. So can I do this in C#? </p>
| c# | [0] |
5,469,361 | 5,469,362 | Converting values using a text file | <p>I'm trying to write a console application in C# which allows a user to enter the following information in the format x,pound,ounce where X is the value to be converted.</p>
<p>I've created a text file which contains the conversion factors in the following format.</p>
<p>pound,ounce,16.0</p>
<p>What I want the application to do is to grab the user input and then find the correct conversion factor within the text file and then calculate the result.</p>
<p>I've tried using a Node class to cycle through the list of conversion factors but it doesn't seem to work =(</p>
<p>Can you help?</p>
| c# | [0] |
3,984,956 | 3,984,957 | Changed server account and php scripts no longer work | <p>I inherited a website that recently changed hosting accounts. Both were on virtual servers. On the new account several of the php scripts have stopped working. They were working before the change.</p>
<p>I've already tried changing register_globals and that didn't work.</p>
<p>What other types of settings can I try changing? Things that might stop scripts from working on a different server.</p>
<p>I know this is generic, but I just need some ideas of where to start to troubleshoot the problem.</p>
<p>Thanks.</p>
| php | [2] |
5,173,898 | 5,173,899 | How to only show some of the values in an array in an textbox? | <p>I have come across a problem that i cant salve, What i have is an string array with 60 values in it and they concists of either "vacant" or "reserved". Now what i need to do is to show only those arayy index that are either vacant or reserved and i have no clue on how to go about it. :/ I am stumped to say the least. I know how to get the number of eatch sort in the array so thats no problem.</p>
<p>I just cant figure out how to get those index values into a method that diplays them in my textbox. My thinking is that since i know how many they are i can atleast know the number of iterrations needed to show them all in the textbox.</p>
<p>So please i need some ideas as i am apparently experiencing a major brainfreez :P (both my two grey ones are fighting)</p>
<p>Thanks for any ideas!</p>
<p>//Regards</p>
| c# | [0] |
1,990,980 | 1,990,981 | what is exactly use of PorterDuff.Mode.CLEAR? | <p>I am new to android and try to learn from basic stage...in a sample there is a line like this canvas.drawColor(0, PorterDuff.Mode.CLEAR);
so plz tell me anyone what it is exacltly...?</p>
| android | [4] |
359,674 | 359,675 | Problem to sum two values in Jquery | <p>I can't get the right sum of two values.I want to sum the cena1 and kolicina. (cena1+kolicina) and (cena1*kolicina)
My jquery code</p>
<pre><code><script type="text/javascript">
function izracunaj() {
var sum = 0;
$("#kolicina").each(function() {
var cena = $("#artikel").val().split("-");
var cena1 = cena[1]; // HERE I GET VALUE 0.17
var kolicina = $("#kolicina").val(); // VALUE 10
});
}
</script>
</code></pre>
| jquery | [5] |
5,021,284 | 5,021,285 | how to customoize tcp port number other than default (80) | <p>I'm using a web service and connect it using httpWebRequest.create api. If i change the TCP port number In IIS other than 80 then my application could not connect to it. How can i set port number in System.Url object as set in IIS so that my application can connect to web service.</p>
| c# | [0] |
2,514,445 | 2,514,446 | Noob needs VERY BASIC help. Just need to get/display properties from a variable | <p>I have searched but perhaps just don't understand and need an actual person to help explain. I have a script that generates the following variable:</p>
<pre><code>var trackerResult = {
"sessionId": "16zA06FJt5sp",
"customerId": "16zA06FJt5so",
"contact": {
"firstName": "Bilbo",
"lastName": "Baggins",
"email": "[email protected]"
},
"orders": [{
"orderId": "16zA06FJt5ss",
"number": 11512,
"items": [{
"price": 97,
"productId": "16zA06FJt3of",
"productName": "Main"
}]
}, {
"orderId": "16zA06FJt5sw",
"number": 11513,
"items": [{
"price": 49,
"productId": "16zA06FJt3op",
"productName": "Upsell"
}]
}],
"demoMode": "1"
};
</code></pre>
<p>I need to be able to simply display the productName and the price. If what the script generated were a bit more simple I could do it, but as I understand what I am looking at there is properties that are technically a child of a child?</p>
<p>Thank you in advance.</p>
| javascript | [3] |
1,359,035 | 1,359,036 | How to mimic Split Screen feature of MSWord for Android Screen.? | <p>I want my Android Screen (320*480) to be split into two 2 screens each of resolution 320*240 which should mimic the "split Screen" feature of MS Word .How can this be achieved
Any sample code or any suggestions .
I will be waiting for reply.</p>
<p>Thanks In Advance.</p>
| android | [4] |
3,693,339 | 3,693,340 | Creating Custom AlertDialog ? What is the root view? | <p>what i am trying to do:</p>
<p>Create a custom Alert Dialog. Buttons just like any Alert Dialog but above are two TextEdit input boxes. I don't want to create a custom Dialog but a customized Alert Dialog</p>
<p>Here is what I am trying #3:
<a href="http://developer.android.com/guide/topics/ui/dialogs.html" rel="nofollow">http://developer.android.com/guide/topics/ui/dialogs.html</a></p>
<p>It says:</p>
<pre><code>AlertDialog.Builder builder;
AlertDialog alertDialog;
Context mContext = getApplicationContext();
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.custom_dialog,
(ViewGroup) findViewById(R.id.layout_root));
TextView text = (TextView) layout.findViewById(R.id.text);
text.setText("Hello, this is a custom dialog!");
builder = new AlertDialog.Builder(mContext);
builder.setView(layout);
alertDialog = builder.create();
</code></pre>
<p>Documentation says:</p>
<pre><code>View layout = inflater.inflate(R.layout.custom_dialog,
(ViewGroup) findViewById(R.id.layout_root));
</code></pre>
<p>where the first parameter is the layout resource ID and the second is the ID of the root View.</p>
<p>Problem is I don't know what the layout root is? this is a dialog I am going to kick of in an Activity. Should I use the layout id if the activity? Is layout_root pulled out of a hat?</p>
<p>Also tried:</p>
<pre><code> View layout = inflater.inflate(R.layout.my_custom_layout,
(ViewGroup) findViewById(android.R.id.content).getRootView());
</code></pre>
<p>result null pointer.</p>
| android | [4] |
5,760,809 | 5,760,810 | How can i get Keywords used in a Search Engine in asp.net | <p>Hi how i can used keywords entred in search engine then navigated to my website with asp.net webform ?
Please Help Me
Thanks</p>
| asp.net | [9] |
1,156,659 | 1,156,660 | can you easily mix in one project C# and VB.aspx | <p>you should be able to merge the assemblies... but just wondering if you had a VB.net web app, and then had a C# project, how would you merge the aspx pages? </p>
<p>can it be done? </p>
| asp.net | [9] |
5,272,671 | 5,272,672 | How to send a php variable using a url | <p>I want to for example send the <code>$test</code> in a url then I want to use <code>$_GET</code> ti get the variable.</p>
<p>This is probably a stupid question but if you have another way of doing this then please let me know. By the way I would usually use include for this but I can't use it this time because of some really long reason. The other option I considered was fwrite. The problem with this is that multiple users will be trying to write this files at once. Its just not practical.</p>
<p>Any help or hints will be great. Thanks guys. Sorry for the stupid question</p>
| php | [2] |
5,301,978 | 5,301,979 | What using statement must be added to use the Backup class in c# | <p>I want to use the <code>Backup</code> class to make a backup of my database. </p>
<p><code>Backup backup =new Backup();</code></p>
<p>However, I do not know what namespace this class is found in.</p>
<hr>
<p>I added Microsoft.SqlServer.SmoExtended.dll And Microsoft.SqlServer.Smo.dll</p>
<p>Now its Work !</p>
<p>Thanks all</p>
| c# | [0] |
2,684,994 | 2,684,995 | what is on stack in Iphone | <p>In objective C whenver we create any object (i.e. uiview <em>myview</em>), it is stored on heap. Can anybody please tell what is stored on stack?</p>
| iphone | [8] |
5,025,436 | 5,025,437 | Installing one apk with two different entry point | <p>In my application it contain activity A,B,C,D. Now, I want to enter in to my application with two different entry point. That means i want to enter from activity A as well as activity C. If I give intent filter like:</p>
<pre><code><intent-filter>
<action android:name="android.intent.action.MAIN"
<category android:name="android.intent.category.LAUNCHER"
<intent-filter>
</code></pre>
<p>for both activity A and C two icons will create in application launcher,but both are work same
that means if I click any icon it start from beginning, but my requirement is one icon as to start from beginning(Activity A) and other from Activity C.</p>
<p>How to achieve this? </p>
| android | [4] |
327,953 | 327,954 | need to add pushviewcontroller in view based application | <pre><code> -(void)buttonClicked:(id)sender{
NSLog(@"welcome button");
testWebView = [[[TestWebView alloc]init] autorelease];
[self presentModalViewController:testWebView animated:YES];
[testWebView test];
}
</code></pre>
<p>i trigger the buttonclicked and there i need to do PushViewController.</p>
<p>My application is view based application</p>
<p>@All</p>
<p>Thanks in advance./</p>
| iphone | [8] |
3,426,903 | 3,426,904 | Any way to tell when any button in a layout is UN-pressed | <p>(Android 3.2) I have a TableLayout with 9 buttons. I want to know when any of them are un-pressed, i.e., when a press is complete, i.e., ACTION_UP. I don't care which button, I just want to know when any button which had been pressed has just been released.</p>
<p>I was hoping there was an <strong>Android::onTouch</strong> in the XML, like there is an Android::onClick, and I could point them all at one onTouch event handler to look for an ACTION_UP. But there isn't. I'm trying to avoid writing 9 separate OnTouchListeners.</p>
<p>Any suggestions?</p>
<p>Thanks in advance.</p>
| android | [4] |
2,940,997 | 2,940,998 | Howto read updated shared preferences between applications? | <p>I met an issue very similar with the following, but it's different.</p>
<p><a href="http://stackoverflow.com/questions/11378975/howto-read-updated-shared-preferences">Howto read updated shared preferences?</a></p>
<p>I've two applications, A.apk has quite a few sharedPreferences need to be fetched from B.apk. I can totally read it from B without a problem. However, when the preferences of A are changed, and then return to B.apk (onResume). Now the preferences fetched from A are not updated. I've to force close the B.apk and restart it to read the updated preferences.</p>
<p>I've also tried to use finish() while leaving A, however, it's not working. Any suggestion?</p>
| android | [4] |
4,009,145 | 4,009,146 | Updating the App Widget from the configuration Activity and getting the result value | <p>In my Weather App Widget, i'm updating Widget from the configuration activity using the place name entered by the user for the first time.After updating the widget, i'm creating a return intent and finishing the activity. I'm giving the code below.</p>
<pre><code>Intent resultValue = new Intent();
resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, mAppWidgetId);
setResult(RESULT_OK, resultValue);
finish();
</code></pre>
<p>But how i'll get the return value(placename) in the AppWidgetprovider class,so that i can update the widget automatically at a later time.
Thanks in Advance.</p>
| android | [4] |
2,854,057 | 2,854,058 | Aligning textviews on the left and right edges in Android layout | <p>Getting started with Android and having trouble getting a simple layout going. </p>
<p>I would like to use a LinearLayout to position two TextViews in a single row. One TextView on the left hand side, the other on the right hand side (analogous to float:left, float:right in CSS).</p>
<p>Is that possible or do I need to use a different ViewGroup or further layout nesting to accomplish it?</p>
<p>Here's what I have so far:</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:orientation="horizontal" android:padding="10sp">
<TextView android:id="@+id/mytextview1" android:layout_height="wrap_content" android:text="somestringontheleftSomestring" android:layout_width="wrap_content"/>
<TextView android:id="@+id/mytextview2" android:layout_height="wrap_content" android:ellipsize="end"
android:text="somestringontheright" android:layout_width="wrap_content"/>
</LinearLayout>
</code></pre>
| android | [4] |
4,553,708 | 4,553,709 | dir() a __class__ attribute? | <pre><code>class Foo:
pass
>>> f = test.Foo()
</code></pre>
<p>Lets look into the class instance ...</p>
<pre><code>>>> dir(f)
['__add__', [__class__] ...]
</code></pre>
<p>Oooh! Lets look into the class instance metadata ...</p>
<pre><code>>>> dir(f.__class__)
['__add__', [__class__] ...]
</code></pre>
<p>hmm ... was expecting attributes of <code>__class__</code> ; but returns back attributes of <code>f</code></p>
<p>Trying a hit and trial ...</p>
<pre><code>>>> dir(f.__class__.__class__)
['__abstractmethods__', '__base__' ...]
</code></pre>
<p>hmm ... why twice a charm?</p>
| python | [7] |
3,270,885 | 3,270,886 | Check if value exists in comma separated string with PHP | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/2322505/comma-separated-string-to-array">comma-separated string to array</a> </p>
</blockquote>
<p>I need to check if my id exists in comma separated string.</p>
<p>My string is saved as <code>"1,2,3,4,10"</code> in database.</p>
<p>I have tried </p>
<pre><code>$HiddenProducts = array($sqlvalue);
if (in_array(2, $HiddenProducts)) {
echo "Available";
} else {
echo "Not available";
}
</code></pre>
<p>It is not working. Any solutions please...</p>
| php | [2] |
2,929,497 | 2,929,498 | C++ Constructor / Class Question: Error - left of must have class/struct/union | <p>I realise what this error means, the thing that is puzzling me is why I get it. I have emulated the error in this tiny program for the sake of this question. Here is the code:</p>
<p>source file:</p>
<pre><code>#include "RandomGame.h"
using namespace std;
NumberGame::NumberGame(int i)
{
upperBound = i;
numberChosen = 1 + rand() % upperBound;
}
NumberGame::NumberGame()
{
upperBound = 1000;
numberChosen = 1 + rand() % upperBound;
}
int NumberGame::guessedNumber(int g)
{
if (g == numberChosen)
{
return 2;
}
else if (g < numberChosen)
{
return 0;
}
else
{
return 1;
}
}
</code></pre>
<p>header file: </p>
<pre><code>#ifndef NUMBERGAME_H
#define NUMBERGAME_H
#include <iostream>
using namespace std;
class NumberGame
{
private:
int upperBound;
int numberChosen;
int g;
public:
NumberGame(int);
NumberGame();
int guessedNumber(int);
};
#endif
</code></pre>
<p>main:</p>
<pre><code>#include <iostream>
#include <cstdlib>
#include "RandomGame.h"
using namespace std;
int makeEven(int);
int main()
{
//only one of these lines will remain uncommented
NumberGame newNumberGame(5); // works
NumberGame newNumberGame; // works
NumberGame newNumberGame(); // doesn't work
// I get the error here, apparently when using empty brackets, newNumberGame
//is not a class anymore. wwwhhyyyyy??????
newNumberGame.guessedNumber(5);
return 0;
}
</code></pre>
<p>I haven't done C++ in a while so i'm sure it's something really simple, but why doesn't the empty brackets work? btw it also doesn't work if I just have one constructor with no arguments, or one constructor with a default argument. </p>
| c++ | [6] |
5,815,173 | 5,815,174 | :last not only remove last element | <p>I'm trying to make my own search name, a facebook-like-search (autocomplete), as in facebook's compose message. My whole script is at <a href="http://jsfiddle.net/6YbrP/4/" rel="nofollow">http://jsfiddle.net/6YbrP/4/</a>.</p>
<p>The problem is I'm stucked at this code :</p>
<pre><code>.keyup(function(e){
if(e.keyCode == 8 && $(this).val() == ''){
$('#itemcontainer div.detailwrapper:last').remove();
}
});
</code></pre>
<p>It does remove the last element, IF I just clicked the box and then press backspace button. BUT NOT when I clicked inside the box, then clicked outside the box, clicked inside the box again, and re-press backspace key. It deleted/ removed 2 last elements, not only the last element. How could this happen? And how could I fixed it?</p>
<p>Thank you for any responses.</p>
| jquery | [5] |
4,154,236 | 4,154,237 | When was Java's "System.out.println()" overloaded? | <p>Could it still take, for example, an int and print it successfully?</p>
| java | [1] |
2,703,045 | 2,703,046 | javascript validation error | <p>here's my code, which says error when i run it through w3.validator.org.</p>
<p>for (var i = 0; i < CheckBox.length; i++) </p>
<p>error message -
character "<" is the first character of a delimiter but occurred as data </p>
<p>how do i fix this?</p>
| javascript | [3] |
2,147,452 | 2,147,453 | Passing items From DataTable to SQL Where Clause c# | <p>I have a single column Datatable, I want to pass this datatable in SQL where clause using sqlparametercollection. Please help.
below is my code:</p>
<pre><code>public DataTable getCatsByDepts(DataTable _Depts)
{
SqlConnection conn = new SqlConnection("Server=ax12d;Database=DemoDataAx;Trusted_Connection=True;");
SqlCommand cmd = new SqlCommand("Select Level2 as Category from Mtq_RetailHierarchy Where Level1 IN (@Depts)", conn);
foreach (DataRow row in _Depts.Rows)
{
cmd.Parameters.Clear();
cmd.Parameters.AddWithValue("Department", row.Field<string>("Department"));
//cmd.ExecuteNonQuery();
}
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable SelectedCatsData = new DataTable();
da.Fill(SelectedCatsData);
return SelectedCatsData;
}`
</code></pre>
| c# | [0] |
3,613,649 | 3,613,650 | builtin function for string value | <pre><code>strvalues=@"Emp_Name;Emp_ID;23;24;25;26";
</code></pre>
<p>contains values like this
taking the above string as an input the output should be like this</p>
<pre><code>string strresult=@"23;24;25;26";
</code></pre>
<p>is there any built in function to do like this</p>
<p>thnaks
prince</p>
| c# | [0] |
4,149,943 | 4,149,944 | how to set range in text field for numeric up and down? | <p>how to set range in text field for numeric up and down?More over the value in the text box can be increase and decrease using up and down key also?</p>
<p>i am using textbox with two images(up and down) like (for increment) and (for decrement) here how can i set range 0 to 100 (i am working in struts) </p>
| javascript | [3] |
5,445,957 | 5,445,958 | Is it OK to initialize a reference member with dynamically allocated memory? | <p>Am I causing a memory leak here or is it OK to do like this? Should I use a smart pointer member instead of a reference?</p>
<pre><code>class A
{
public:
A() : b_(*(new B))
{}
private:
B& b_;
};
int main()
{
A a;
return 0;
}
</code></pre>
| c++ | [6] |
3,056,750 | 3,056,751 | Object Creation in Android Componets | <p>I am trying to make myself clearer in android component instance creation.
I believe any activity itself is an instance (correct me if i am wrong) but what would actually call " new " for object/instance creation? how does this whole stuff works in android framework... do we use super() in each component for that ? (to create that instance) which calls the base class's (Activity) constructor and it eventually calls "new" and creates the new instance for its derived class? </p>
| android | [4] |
1,502,813 | 1,502,814 | Java Spam Filter | <p>I'm trying to create a spam filter in Java using the Bayesian algorithm.</p>
<p>I use a text file that contains email messages and split the tokens using regex, storing these values into a hashmap.</p>
<p>My problem is, with regex, the email addresses are split so instead of:
[email protected]</p>
<p>regex causes the token to be:
john
smith
example</p>
<p>The same holds true for ip addresses, so for example, instead of:
192.55.34.322</p>
<p>regex splits the tokens to be:
192
55
34
322</p>
<p>So does anybody know of a way that I could read the email messages and store their contents as is? </p>
<p>AMENDMENT: I am using a regex that does not keep ip addresses or email addresses. It splits these up.</p>
<p>I was wondering if regex was not the way to go and if I could be suggested any alternatives for me to be able to filter emails to pick out characteristics I desire.</p>
| java | [1] |
216,960 | 216,961 | Error Installing Android SDK Platform Tools | <p>I have downloaded eclipse, the android SDK starter package, and installed the "Developer Tools." Following the guide on developer.android.com exactly. After the developer tools have installed, and eclipse restarts I get two error messages: </p>
<p>1: <code>"SDK Platform Tools component is missing!
Please use the SDK Manager to install it."</code></p>
<p>So, I go in eclipse under Windows > Android SDK Manager and while trying to fetch the files it brings up the sdk manager log with the following:</p>
<pre><code> Fetching https://dl-ssl.google.com/android/repository/addons_list-1.xml
Failed to fetch URL https://dl-ssl.google.com/android/repository/addons_list-1.xml, reason: Invalid argument: connect
Fetched Add-ons List successfully
Fetching URL: https://dl-ssl.google.com/android/repository/repository-5.xml
Failed to fetch URL https://dl-ssl.google.com/android/repository/repository-5.xml, reason: Invalid argument: connect
Done loading packages.
</code></pre>
<p>Because of this error I cannot use the SDK Manager to install it. Any ideas on how to fix this?</p>
<p>2: "Failed to initialize Monitor Thread: Unable to establish loopback connection."
No idea what this one means.</p>
<p>Any help would be greatly appreciated. I have spent a few hours googling trying to find fixes but nothing seems to work, or the fixes refer to a non-existent "settings" window. </p>
| android | [4] |
470,519 | 470,520 | PHP upload - Why isset($_POST['submit']) is always FALSE | <p>I have the following code sample upload3.php:</p>
<pre><code><html>
<head>
<title>PHP Form Upload</title>
</head>
<body>
<form method='post' action='upload3.php' enctype='multipart/form-data'>
Select a File:
<input type='file' name='filename' size='10' />
<input type='submit' value='Upload' />
</form>
<?php
if (isset($_POST['submit']))
{
echo "isset submit";
}
else
{
echo "NOT isset submit";
}
?>
</body>
</html>
</code></pre>
<p>The code always returns "NOT isset submit".
Why does this happen? Because the same script upload3.php calls itself?</p>
| php | [2] |
5,533,404 | 5,533,405 | LinkedList...inheritance...what? | <p>I don't understand what this homework is asking me to do...</p>
<p>In our last project, we created a person.java class that made an array of people (or just instances of people)...and it had their ID, their mom, their dad, birthdate, number of children, and an array of their children. It had predictable methods like get or set mom and dad, add child, remove child, unset mom or dad, boolean to see if another instance is or is not a child of this instance, get sex, get id...i think that was it.</p>
<p>Anyway...the point of this project is to make small changes to our last project to allow unlimited number of children for each person class. The last project had a static int variable for the maximum number of allowable children set to 10.</p>
<p>To do this, we're to implement a list. And create another class called personlist.java, which is to be a sublcass of java.util.LinkedList. We have to make sure to save Person.java in the same project where we create PersonList.java so that the compler can recognize java.util.LinkedList. The PersonList class should transparently handle all methods related to adding/removing/finding the children of a person. Since PersonList is a subclass of LinkedList, we will have all the LinkedList methods available to us.</p>
<p>I don't even know where to start. I still have my Person.java class. I'm using Eclipse...so I made a new project. Made a class called PersonList.java. Made another class called Person.java and copied my old project into it.</p>
<p>How do I declare the new class so that it "communicates" with Person.java?</p>
<pre><code>import java.util.LinkedList;
public class PersonList extends LinkedList<Person> {
}
</code></pre>
<p>Is that right? I'm also confused as to why we weren't told to just modify Person.java to utilize linked lists. I can do that. Why create another class called PersonList.java? And what the heck goes in there? How do I call methods in PersonList.java from Person.java?</p>
<p>Any insight would be greatly appreciated!</p>
| java | [1] |
966,391 | 966,392 | Find the closest object (before and after) to the target object | <p>I want to Implement the two methods given below. <strong>SomeObject</strong> has a field <strong>createdDate</strong> of type Date</p>
<pre><code>private SomeObject getNearestObjectBeforeTargetObjectsCreatedDate(List<SomeObject> someObjectList, SomeObject targetObject){
}
private SomeObject getNearestObjectAfterTargetObjectsCreatedDate(List<SomeObject> someObjectList, SomeObject targetObject){
}
</code></pre>
<p>Suppose I have 5 objects P1, P2, P3, P4, P5 in ascending order of created dates. And <strong>target object is P3</strong>, then <strong>1st method should return P2</strong> and <strong>second should return P4</strong></p>
<p>Currently I have wirtten something like this</p>
<pre><code>private SomeObject getNearestPortFolio(List<SomeObject> someObjectList, SomeObject targetObject){
SomeObject returnObject = targetObject;
for(SomeObject someObject : someObjectList) {
// if the current iteration's date is "before" the target date
if(someObject.getCreatedDate().compareTo(targetObject.getCreatedDate()) < 0) {
if (someObject.getCreatedDate().compareTo(returnObject.getCreatedDate()) > 0){
returnObject = someObject;
}
}
}
return returnObject;
}
</code></pre>
| java | [1] |
897,977 | 897,978 | sort() function in C++ | <p>I found two forms of sort() in C++:</p>
<p>1) sort(begin, end);</p>
<p>2) XXX.sort();</p>
<p>One can be used directly without an object, and one is working with an object.</p>
<p>Is that all? What's the differences between these two sort()? They are from the same library or not? Is the second a method of XXX? </p>
<p>Can I use it like this</p>
<pre><code>vector<int> myvector
myvector.sort();
</code></pre>
<p>or</p>
<pre><code>list<int> mylist;
mylist.sort();
</code></pre>
| c++ | [6] |
208,461 | 208,462 | is there a native php function to see if one array of values is in another array? | <p>Is there a better method than loop with strpos()?</p>
<p>Not i'm looking for partial matches and not an in_array() type method.</p>
<p>example needle and haystack and desired return:</p>
<pre><code>$needles[0] = 'naan bread';
$needles[1] = 'cheesestrings';
$needles[2] = 'risotto';
$needles[3] = 'cake';
$haystack[0] = 'bread';
$haystack[1] = 'wine';
$haystack[2] = 'soup';
$haystack[3] = 'cheese';
//desired output - but what's the best method of getting this array?
$matches[0] = 'bread';
$matches[1] = 'cheese';
</code></pre>
<p>ie:</p>
<p>magic_function($haystack, %$needles%) !</p>
| php | [2] |
2,609,721 | 2,609,722 | Get style tag content with jQuery? | <p><strong>The problem</strong></p>
<p>I'm trying to get the content <strong><em>within the style tags</em></strong> but I can't get it to work.</p>
<p><strong>What the code does</strong></p>
<p>I use jQuery and try to get the style content with text() and html(). It does not work.</p>
<p><strong>My code</strong></p>
<pre><code><!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title></title>
<link rel="stylesheet/less" type="text/css" href="css/style.less">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js" type="text/javascript"></script>
<style id="less:concepts-less-css-style" media="screen" type="text/css">
body {
padding: 10px;
background: blue;
}
</style>
</head>
<body>
<script src="js/less-1.1.5.min.js" type="text/javascript"></script>
<script type="text/javascript">
jQuery(document).ready(function($) {
var my_id = $('style').attr('id');
var test = $('#less:concepts-less-css-style').text();
var test2 = $('#less:concepts-less-css-style').html();
alert(test + "#" + test2 + "#" + my_id);
});
</script>
</body>
</html>
</code></pre>
| jquery | [5] |
2,383,551 | 2,383,552 | xml parsing from web service image's | <p>I need to parse xml. my xml do have image links.....</p>
<p>Example my xml..</p>
<pre><code><root>
<child id='1'> child One</child>
<childe2> Child two </child2>
<image>http://website........link.</image>
<image>http://website........link.</image>
<image>http://website........link.</image>
</root>
</code></pre>
<p>now i have taken NSMutableArray for loading images....</p>
<p>is this procedure is correct. any alternative i can implement. </p>
<p>Thanks in advance.</p>
| iphone | [8] |
1,624,381 | 1,624,382 | How to subclass UIApplication? | <p>The iPhone Reference Libary - UIApplication says I can subclass UIApplication, but if I try this I will get an exception:</p>
<pre><code>*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'There can only be one UIApplication instance.'
</code></pre>
<p>This reminds me of the Highlander "There can be only one,. :-)</p>
<p>Do I have to pass other argurments to UIApplicationMain? Or did I missread somthing in the libary?</p>
| iphone | [8] |
2,507,188 | 2,507,189 | Protecting a Hyperlink in android | <p>I have an android application in which i have a hyperlink which opens in a browser.Its Right that Hyperlink on visible when any one enter right password otherwise it remain invisible.Problem is that if any one view the hyperlink by entering a correct password in browser then he will never need to again open the android app to open the hyperlink,So finally i want that user have to open the android app every time when he wants to view the page behind hyperlink. Here is My code through which i am making a hyperlink.</p>
<pre><code>Password=(EditText)findViewById(R.id.pass);
login=(Button)findViewById(R.id.login);
txtDash=(TextView)findViewById(R.id.txtDash);
String linkText = "Visit the <a href='http://sml.com.pk/a/cms/cmsdbandroid.php'>CMS Dashboard</a> web page.";
txtDash.setText(Html.fromHtml(linkText));
txtDash.setMovementMethod(LinkMovementMethod.getInstance());
login.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View V) {
try {
if (Password.getText().toString().equals("dsml"))
{
txtDash.setVisibility(View.VISIBLE);
login.setVisibility(View.INVISIBLE);
Password.setVisibility(View.INVISIBLE);
}
else
{
Toast.makeText(getBaseContext(), "invalid password - try again", Toast.LENGTH_SHORT).show();
}
}catch(Exception e){
//Log.e("log_tag", "Error"+e.toString());
Toast.makeText(getBaseContext(), e.toString(), Toast.LENGTH_SHORT).show();
}
}
});
</code></pre>
<p>Please Any One Help me to do this</p>
| android | [4] |
384,864 | 384,865 | Default value of memberfunction in python | <pre><code>class foo():
def __init__(self,a):
self.A=a
def foo2(self,aa=self.A):
return "la"
@classmethod
def test(cls):
d=foo()
d.foo2()
</code></pre>
<p>The memberfunction foo2 cannot find self.A nor A. Is it because A is not globally set inside the class? </p>
| python | [7] |
1,493,845 | 1,493,846 | Javascript not running from address bar | <p>I have written the following Javascript code : </p>
<pre><code>var outerFrame = document.getElementById("myframe");
var outerDoc = outerFrame.contentDocument || outerFrame.contentWindow.document;
var innerFrame = outerDoc.getElementsByName("frame").item(0);
var innerDoc = innerFrame.contentDocument || innerFrame.contentWindow.document;
var arr=[10,11,12,13,14,15,16,17,18,19,110,111,112,113,114,115,116,117,118,119];
for(i=0;i<20;i++){
var randomVal = Math.floor((Math.random()*5));
if (innerDoc.getElementsByName("point"+arr[i])[randomVal]) {innerDoc.getElementsByName("point"+arr[i])[randomVal].checked = true; }
}
</code></pre>
<p>I want people to be able to run it when on a particular website by copy-pasting it to the address bar. A little Google search tells me I need to append 'javascript:' before it. However, it does not work; nothing happens when I try to execute the code from the address bar. The code runs fine when I execute it from the console.</p>
<p>An error that comes up when trying to execute it from the address bar is :</p>
<blockquote>
<p>uncaught exception: ReferenceError: document is not defined</p>
</blockquote>
<p>Any help ?</p>
| javascript | [3] |
3,131,677 | 3,131,678 | save values on elements with same property javascript | <p>I have an array of several entries with some of them with same name .All entries have location but one is empty.I want to save the same value of location into all entries of the array for same user. How can I do that?</p>
<pre><code> array=[{
user: angelos,
user_id: 121212,
date: 12/12/12,
profile_img: cfdf,
text: nhkjhgjtdkghd,
url: g.htm,
location:Romania
},{
user: angelos,
user_id: 121212,
date: 12/12/12,
profile_img: cfdf,
text: nhkjhgjsdfsadstdkghd,
url: g.htm,
location:""
},{
user: Mike,
user_id: 121212,
date: 12/12/12,
profile_img: cfdf,
text: nhkjhgjtdkghd,
url: g.htm,
location:New York
},{
user: Mike,
user_id: 121212,
date: 12/12/12,
profile_img: cfdf,
text: nhkjhgjsdfsadstdkghd,
url: g.htm,
location:""
}];
</code></pre>
| javascript | [3] |
1,101,962 | 1,101,963 | Detecting whether innerHtml is readonly | <p>I understand that some HTML tags have a readonly innerHtml property in some browsers, e.g. in Internet Explorer,</p>
<p>"The innerHTML property is read-only on the col, colGroup, frameSet, html, head, style, table, tBody, tFoot, tHead, title, and tr objects."</p>
<p><a href="http://msdn.microsoft.com/en-us/library/ms533897(VS.85).aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/ms533897(VS.85).aspx</a></p>
<p>The question is, how do you detect whether this is the case without resorting to a generic browser detect? Simply checking for the property a la</p>
<p><a href="http://www.quirksmode.org/js/support.html" rel="nofollow">http://www.quirksmode.org/js/support.html</a></p>
<p>won't differentiate between writable and read-only properties</p>
| javascript | [3] |
1,526,414 | 1,526,415 | How do I pipe the output of file to a variable in Python? | <p>How do I pipe the output of file to a variable in Python?</p>
<p>Is it possible? Say to pipe the output of <code>netstat</code> to a variable x in Python?</p>
| python | [7] |
863,442 | 863,443 | Will I get a copy or assignment with this initialization? | <p>Compare these two initialization methods in C++ for a trivial complex number class.</p>
<pre><code>complx one(1,3);
complx two = complx(3,4);
</code></pre>
<p>In the second case, will I get a constructor followed by an assignment, followed by a copy, or just the constructor? </p>
<p>Is it possible to distinguish the two types of initializations ?</p>
| c++ | [6] |
536,201 | 536,202 | Checking to see if a URL is Google | <p>I want to check a URL to see if it is a Google url or not.</p>
<p>I've got this function</p>
<pre><code>function isValidURL($url)
{
return preg_match('|^http(s)?://google.com|i', $url);
}
</code></pre>
<p>If i try</p>
<pre><code>if ( isValidURL('http://google.com/') ){
echo 'yes its google url';
}
</code></pre>
<p>It works fine. But if I try</p>
<pre><code>if ( isValidURL('http://www.google.com/') ){
echo 'yes its google url';
}
</code></pre>
<p>(with <code>www</code>) I get an error!</p>
| php | [2] |
3,732,210 | 3,732,211 | Open application in last state it was in | <p>when the user clicks on the icon in the app drawer to start my application, my app opens in the state it was last in.</p>
<p>I have a broadcast receiver, and when I receive a certain intent I want to have the same effect. </p>
<p>At the moment I use </p>
<pre><code>Intent launchIntent = mContext.getPackageManager().getLaunchIntentForPackage("xx.xx.xx"); //My package name
context.startActivity(launchIntent);
</code></pre>
<p>But this always opens the mainactivity of my application.</p>
<p>How can I fix this? thx</p>
| android | [4] |
5,849,865 | 5,849,866 | Setting opacity to a shape | <p>I have a shape like this:</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<stroke
android:width="1dp"
android:color="#d5dce5" />
<corners android:radius="5dp" />
<gradient
android:angle="270"
android:centerColor="#e7eff8"
android:endColor="#e9f0f8"
android:startColor="#e0e8f1" />
</shape>
</code></pre>
<p>Which I include in my layout like this:</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
....
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rectangle"
android:layout_width="276dp"
android:layout_height="wrap_content"
android:background="@drawable/rectangle"
android:layout_gravity="center_horizontal">
</LinearLayout>
....
</LinearLayout>
</code></pre>
<p>How can I set the opacity of this shape to 50 % ? Is it possible? </p>
| android | [4] |
948,476 | 948,477 | Writing data from different classes to a text file using BufferedWriter | <p>I am working with Java.</p>
<p>I have created one text file. In that text file, I want one value to be stored in the text file from class1. Then I want one more value to be stored in the textfile from class2 on the 2nd line. Then I want one more value to be stored in line 3 of the text file from class 3 , etc. The text file, when retrieved, should look like this:</p>
<pre><code>77
65
34
</code></pre>
<p>The problem I encounter is that, the text file content gets erased when I move on to the next class. For example, the text file would only show the last data value. And erase the previous ones (in the example above, only 34 would appear that too on the first line, when it should be on the 3rd line). </p>
<p>Some code from class1:</p>
<pre><code>BufferedWriter outputFile0=null;
try {
int x = value_MAP();
FileWriter fwriter0 =new FileWriter("MAP_allData.txt");
outputFile0 = new BufferedWriter(fwriter0);
outputFile0.write(""+x);
outputFile0.newLine();
} catch( Exception y ) {y.printStackTrace();}
</code></pre>
<p>Same code again appears in class2, class3, etc:</p>
<pre><code>BufferedWriter outputFile0=null;
try {
int x = value_MAP();
FileWriter fwriter0 =new FileWriter("MAP_allData.txt");
outputFile0 = new BufferedWriter(fwriter0);
outputFile0.write(""+x);
outputFile0.newLine();
} catch( Exception y ) {y.printStackTrace();}
</code></pre>
<p>So is there a way to tell Java that dont worry about erasing the data, just add data one line after another when traveling from class 1 to class x. </p>
| java | [1] |
4,465,922 | 4,465,923 | Error when remove value of tag <tr> | <pre><code>jQuery('.chk').click(function(){
for(var k=0; k<2; k++) {
deleteRow(k);
}
});
</code></pre>
<p>And function deleteRow()</p>
<pre><code>function deleteRow(id) {
var table = document.getElementById("modem_list");
var rowName = 'row_'+id;
if (table.rows.namedItem(rowName)) {
table.deleteRow((table.rows.namedItem(rowName).rowIndex));
}
}
<table id="modem_list">
<tr name="row_1">Test 1</tr>
<tr name="row_2">Test 2</tr>
</table>
<a class="chk" href="">CLICK</a>
</code></pre>
<p>When i click is result not delete 2 tag , how to fix it ?</p>
| jquery | [5] |
3,357,871 | 3,357,872 | jQuery Scrollbar Plugin that shows bar and offers function only if there is an overflow | <p>I am looking for a small jQuery plugin, which shows a scrollbar next to a box with an overflow, something like this:</p>
<p><a href="http://baijs.nl/tinyscrollbar/" rel="nofollow">http://baijs.nl/tinyscrollbar/</a>
(1st example)</p>
<p>The Problem:
The scrollbar shall only be shown if there is a real overflow. If the content fits the parent, no scrollbar shall be shown. The jQuery Mousewheel Plugin should be supported, too. </p>
<p>Does somebody know a jQuery Scroll Plugin, which has this function? </p>
| jquery | [5] |
3,545,164 | 3,545,165 | debug android : connect to sqlite db on phone | <p>I'm building an application with a SQLite db in it. Some data is not erased as it should be, I'd like to run ad hoc queries in the existing db to debug. </p>
<p>Is there a way to connect to the SQLite db on the phone (or the emulator) while in debug mode? </p>
| android | [4] |
4,866,272 | 4,866,273 | How to use LayerManager in Java | <p>I am beginner with Java. I have a question about how to create a map which has multiple layers just like flash (layer 1,layer 2, etc).</p>
<p>I don't have any ideas how to create layers in the map. For example, layer 1 is construct with background image, layer 2 is construct with static image icon like road, layer 3 is constructed with buildings, and etc.</p>
<p>Any tutorials can refer?</p>
<p>Any one has any solution for this?</p>
| java | [1] |
1,597,465 | 1,597,466 | Replace text with on page load | <p>I know how to replace text with <code>getElementById()</code> function in such situation:</p>
<pre><code><script type="text/javascript">
function go(){
var p = document.getElementById('ccc');
p.firstChild.nodeValue = 'AAA';
}
</script>
<div id='ccc'>o</div>
<a href="javascript:go()">go</a>
</code></pre>
<p>When I click on go link 'o' replaces on 'AAA'.</p>
<p>But I want to replace text when page loading to browser without any clicking. So user do not have to know that there was some text 'o' in div 'ccc'. He must see only 'AAA' from the beginning.</p>
<p>How to do that?</p>
| javascript | [3] |
4,162,742 | 4,162,743 | How do I load instances of a certain class from a java directory? | <p>Here's my method:</p>
<p>Feature[] getFeatures(File dir)</p>
<p>I'm trying to go through the directory, check each class file. Any class that is of type 'Feature', I want to load an instance of it. Then I want to return an array of these instances.</p>
<p>How is this done?</p>
<p>Thank you.</p>
<p>EDIT:</p>
<p>Here's what I have now:</p>
<pre><code>private static LinkedList<Feature> getFeaturesInDirectory(File dir) throws ClassNotFoundException {
LinkedList<Feature> features = new LinkedList<Feature>();
ClassLoader cl = new IndFeaClassLoader();
// list all files in directory
for(String s : dir.list()) {
Class klass = cl.loadClass(s);
try {
Object x = klass.newInstance();
if (x instanceof Feature) {
features.add((Feature)x);
}
} catch (InstantiationException ex) {
} catch (IllegalAccessException ex) {
}
}
return features;
}
</code></pre>
| java | [1] |
1,261,683 | 1,261,684 | What is the diferrence between object and Object | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/1017282/c-difference-between-system-object-and-object">c#: difference between “System.Object” and “object” </a> </p>
</blockquote>
<p>What is the diferrence between object and Object</p>
| c# | [0] |
3,660,742 | 3,660,743 | use jquery addclass and removeclass | <p>i am making a lightbox code which requires me to use jquery <code>addClass</code> and i also require to use <code>removeClass</code> but i am not able to do that . my code is </p>
<pre><code> var d = this.buttons;
if (c("body").find("#lightbox-buttons").length < 1) {
this.list = c(a.template || this.template).addClass(a.position || "top").prependTo(g.utility.find("> div"));
d = {
prev: this.list.find(".btnPrev").click(g.prev),
next: this.list.find(".btnNext").click(g.next),
play_fast: this.list.find(".btnFast").click(g.play_fast).addClass(g.player_fast.isActive ? "btnPlayOn" : "")
}
</code></pre>
<p>like in this line i also need to use removeClass to remove a class from one more button. </p>
<p><code>play_fast: this.list.find(".btnFast").click(g.play_fast).addClass(g.player_fast.isActive ? "btnPlayOn" : "")</code></p>
| jquery | [5] |
402,518 | 402,519 | Pros and cons of hosted scripts | <p>I have seen some developers use hosted scripts to link their libraries.</p>
<p><code>cdn.jquerytools.org</code> is one example.</p>
<p>I have also seen people complain that a hosted script link has been hijacked.</p>
<p>How safe is using hosted scripts in reality? Are the scripts automatically updated? For example, if jQuery 5 goes to 6 do I automatically get version 6 or do I need to update my link?</p>
<p>I also see that Google has a large set of these scripts setup for hosting. </p>
<p>What are the pros and cons?</p>
| jquery | [5] |
497,031 | 497,032 | Java JDBC Query with variables? | <pre><code>String poster = "user";
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM `prices` WHERE `poster`="+poster);
</code></pre>
<p>This does not work.Any tips or tricks would be appreciated. </p>
| java | [1] |
4,840,407 | 4,840,408 | list of lists creation | <p>in my python code i want to create a list of lists...in a loop ...
but after completion of the loop i end up with the same list in all elements...is it because the lists are pointed to and not stored ? If so, how can i come up with a solution to my problem ?
Following is my code</p>
<pre><code> list_lists=list()
list_temp=list()
for i in xrange(n):
ind_count =0
del list_temp[0:len(list_temp)]
for j in xrange(no_words):
if inp[i] == words[j]:
list_temp.append(j)
list_lists.append(list_temp)
</code></pre>
| python | [7] |
3,771,706 | 3,771,707 | No simulator option while running the code | <p>I am not able to see Simulator option in my XCODE for one of my project (Only device is there) but it is coming for other one. What setting I need to do?</p>
| iphone | [8] |
2,978,119 | 2,978,120 | JavaScript function doesn't return correct value | <p>I'm developing a function in which I'd like to check which useragent is currently being used.<br>
The following code is just a prototype and it returns whatever value it reads first - in this case <code>IE</code>.</p>
<pre><code>detectDevice = function () {
var userAgent = {
detect: function () {
return navigator.userAgent;
},
detectBrowser: function () {
var browser = userAgent.detect();
var currentBrowser;
return currentBrowser = browser.indexOf('IE') ? "Internet Explore" : browser.indexOf('Mozilla') ? "FireFox" : "UserAgent not recognized!";
},
version: function (identifier) {
}
};
alert(userAgent.detectBrowser());
}
</code></pre>
<p>I can't tell what's wrong. Maybe you guys can see it and tell me where I made a wrong turn.</p>
| javascript | [3] |
9,394 | 9,395 | Inheritance, any suggestions how I should improve this program? | <pre><code>public class Person{
private String name;
private String surname;
private int age;
private String address;
Person(String n, String s, int a, String i){
name = n;
surname = s;
age = a;
address = i;
this.name = name; this.surname= surname;
this.age = age; this.address = address;
}
public String getName() {return name;}
public String getSurname() {return surname;}
public int getAge() {return age;}
public String getAddress() {return address;}
System.out.println(name+surname+age+address);
Person(){
this("Ryan","Borg",25,"Gudja");
}
}
public class Student extends Person{
int mark;
String credits;
Student(){
}
Student(String n, String s, int a, String i, int m, String c){
super(n, s, a, i);
mark = m;
credits = c;
public String getName() {return name;}
public String getSurname() {return surname;}
public int getAge() {return age;}
public String getAddress() {return address;}
public int getMark(){return mark;}
public String getCredits() {return credits;}
System.out.println(name+surname+age+address+mark+credits);
}
}
public class Teacher extends Person{
int salary;
String subject;
Teacher(){
}
Teacher(String n, String s, int a, String i, int sal, String sub){
super(n, s, a, i);
salary = sal;
subject = sub;
public String getName() {return name;}
public String getSurname() {return surname;}
public int getAge() {return age;}
public String getAddress() {return address;}
public int getSalary(){return salary;}
public String getSubject() {return subject;}
System.out.println(name+surname+age+address+salary+subject);
}
}
</code></pre>
| java | [1] |
2,800,155 | 2,800,156 | PHP how to explode string into groups of 6 letters in array | <pre><code>$string = 'billiejeanisnotmylover';
$array = some_function($string,6);
$array[0] = 'billie'
$array[1] = 'jeanis'
$array[2] = 'notmyl'
$array[3] = 'over'
</code></pre>
<p>do you have an idea what some_function would be?</p>
| php | [2] |
3,797,752 | 3,797,753 | ASP.NET dynamic user interface OR form designer | <p>I need to create an application that allows users to design forms for various purposes. basically users should be able to design a form just like developers can do it in design mode using Visual studio (drag and drop controls and add data). for example users should be able to create a set of questions for a survey and as part of questionnaire, they should be able to select various controls and create a template for the questionnaire and save it down in the database, which could then be used by other set of users who actually need to answer that questionnaire. Is this possible to achieve? is there any component that does this already? any help will be appreciated. thanks. Please let me know if the question is not clear, I can add more detail.</p>
| asp.net | [9] |
4,396,417 | 4,396,418 | Remove the static int from this MatchEvaluator | <p>I'm trying to convert a proprietary string mask to the .net equivalent of it.
For that I need to exchange every occurance of [someText] with {aDigit}.</p>
<pre><code>private static int hits = 0;
private static object hitsLock = new object();
public static string ConvertSdsFileMaskToStringMask(string sdsFileMaskString) {
Regex bracketsExpression = new Regex(@"\[[^[]*]");
lock (hitsLock)
{
hits = 0;
return bracketsExpression.Replace(sdsFileMaskString, ReplaceSquareWithAngularBrackets);
}
}
private static string ReplaceSquareWithAngularBrackets(Match m) {
string result = String.Format("{{{0}}}", hits.ToString());
hits++;
return result;
}
</code></pre>
<p>It works. But both expressions need to know each other's workings and are depending on the hits counter. I feel this could be improved. Ideally both have no dependency on each other. Any suggestions?
This can probably be done better. Any suggestions?</p>
| c# | [0] |
4,231,268 | 4,231,269 | stop to go on onPostExecute() if parsing exception onpreexecute() occurs | <p>am using asynchronous task for hitting the web service url and retrieve the result from server but some time in onPreExecute() method if parsing exception occurs i handle it on catch() method,now i want to Halt the processing next means execution not go to OnpostExecute() method ,so how to stop execution process for going it to OnPostExecute()
my code are below </p>
<pre><code> @Override
protected void onPreExecute() {
dialog = new ProgressDialog(MainMenu.this);
dialog.setMessage("Processing...");
dialog.setIndeterminate(true);
dialog.setCancelable(false);
dialog.show();
}
@Override
protected void onPostExecute(final Boolean success) {
if (dialog.isShowing())
{
dialog.dismiss();
}
Intent i = new Intent(MainMenu.this, filterpagetabs.class);
startActivity(i);
}
@Override
protected Boolean doInBackground(final String... args) {
try{
try {
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
XMLReader xr = sp.getXMLReader();
URL sourceUrl = new URL(
"http://www.mobi/iphonejh/output.php?estado=1");
MyXMLHandler myXMLHandler = new MyXMLHandler();
xr.setContentHandler(myXMLHandler);
xr.parse(new InputSource(sourceUrl.openStream()));
} catch (Exception e) {
System.out.println("XML Pasing Excpetion = " + e);
}
</code></pre>
<p>}</p>
| android | [4] |
5,701,653 | 5,701,654 | What does "@Override" and "<? extends Page>" mean? | <pre><code>@Override
public Class< ? extends Page> getHomePage() {
return HomePage.class;
}
public Class<HomePage> getHomePage(){
return HomePage.class;
}
</code></pre>
<p>The first one has an annotation
Override. What does that mean or
what does it send to the framework.</p>
<p>Will both the methods return the same class. I mean what does this mean <code>? extends Page</code>. I mean the ? Mark.</p>
| java | [1] |
3,042,120 | 3,042,121 | How to set button object to an image | <p>I need to customize the look and feel of my android application. I need a PNG file I created to show in place of the button view's default appearance. How can I make this happen?</p>
| android | [4] |
4,936,401 | 4,936,402 | Python - How to transform counts in to m/s using the obspy module | <p>I have a miniseed file with a singlechannel trace and I assume the data is in counts (how can i check the units of the trace?). I need to transform this in to m/s.
I already checked the obspy tutorial and my main problem is that i dont know how to access the poles and zeros and amplification factor from the miniseed file.
Also, do I need the calibration file for this?</p>
<p>Here is my code:</p>
<pre><code>from obspy.core import *
st=read('/Users/guilhermew/Documents/Projecto/Dados sismicos 1 dia/2012_130_DOC01.mseed')
st.plot()
</code></pre>
<p>Thanks in advance,
Guilherme</p>
| python | [7] |
1,753,150 | 1,753,151 | Class construct causes the same code to be executed multiple times | <p>let me introduce you first to the issue that I am experiencing. I've recently started working on my own MVC framework. I want some additional experience and to understand how exactly framework's like CodeIgniter work.</p>
<p>Anyway, everything was going great until I added a construct to my controller. The request was routed properly, the controller has been initialized - the issue is that is gets initialized time after time and continues until resource limit has been reached.</p>
<p>After doing a lot of debugging, I found out that one simple line causes everything, but I don't know how why. This is the line:</p>
<pre><code>$controller = &FuturoContainer::getController();
</code></pre>
<p>To explain the above line. FuturoContainer is my implementation of dependency injection. It contains instances of all classes that should be initialized only once.</p>
<p>This is getController() method:</p>
<pre><code>private static $controller = null;
public static function &getController()
{
if (self::$controller === null) {
/* Load controller file */
require self::getParam('controllerFile');
$controllerName = self::getParam('controllerName');
self::$controller = new $controllerName;
}
return self::$controller;
}
</code></pre>
<p>$controller is null by default.</p>
<p>As I have already mentioned, even though $controller should be a class instance after this method has been executed for the first time, it seems to remain NULL. Not only that, but the method gets executed time after time after time. And the weirdest part: it only happens if I add __construct() to a controller like this:</p>
<pre><code>class Home extends Controller
{
public function __construct()
{
parent::__construct();
}
}
</code></pre>
<p>Any idea why might this happen? Thanks in advance.</p>
| php | [2] |
1,311,122 | 1,311,123 | Is it possible to block or filter websites on an android programmatically? | <p>I want to block certain website in my app is it possible in android ?</p>
<p>thanks in advance</p>
| android | [4] |
4,145,310 | 4,145,311 | Why doesn't Class have a nice generic type in this case? | <p>In this code, why can type not be declared as <code>Class<? extends B></code>?</p>
<pre><code>public class Foo<B> {
public void doSomething(B argument) {
Class<? extends Object> type = argument.getClass();
}
}
</code></pre>
| java | [1] |
4,766,016 | 4,766,017 | Image not shown in tree view , C# | <p>So in my project i would like have a nice treeview that has images.
but when i run the program the image was not shown. Any idea?
here is my code:</p>
<pre><code> while (thisreader.Read()) // i read from the database.
{
TreeNode tn = new TreeNode();
tn.Text = thisreader["channel_name"].ToString();
tn.ImageIndex = 1;
tn.SelectedImageIndex = 1; // i have my imagelist1 in the corresponding winform
treeView1.Nodes.Add(tn);
}
</code></pre>
| c# | [0] |
1,064,493 | 1,064,494 | Don't understand this python For loop | <p>I'm still a python newb, but I'm working through the <a href="http://pyneurgen.sourceforge.net/tutorial_nn.html" rel="nofollow">Pyneurgen neural network tutorial</a>, and I don't fully understand how the for loop used to create the input data works in this instance:</p>
<pre><code>for position, target in population_gen(population):
pos = float(position)
all_inputs.append([random.random(), pos * factor])
all_targets.append([target])`
</code></pre>
<p>What is the loop iterating through exactly? I've not come across the use of the comma and a function in the loop before.</p>
<p>Thanks in advance for any help :)</p>
| python | [7] |
859,509 | 859,510 | How can I convert from numbers to characters? | <p>I have an array of numbers in C#. The numbers range from one to ten. I would like to just show letters for example a letter "b" instead of the number 2. </p>
<p>Is there an easy way for me to do this. </p>
<p>Hope there is. </p>
<p>Maria</p>
| c# | [0] |
1,432,452 | 1,432,453 | Get the index of an array by position | <p>I want to get the index of an array by position. Is this possible? For example, I want the following function to print:</p>
<pre><code>var args = new Array();
args["name"] = "john";
args["surname"] = "smith";
printPerson(args);
function printPerson(args) {
for(var i = 0; i < args.count; i++) {
???
}
}
</code></pre>
<blockquote>
<p>"name:john surname:smith"</p>
</blockquote>
<p>(ie <code>name</code> & <code>surname</code> should not be hardcoded inside function)</p>
<p><strong>EDIT</strong><br>
The order they printed out is not important!</p>
| javascript | [3] |
5,571,603 | 5,571,604 | how to automatically rename object in java | <p>I have list of String.
<code>List<String> elements= new ArrayList<String>();</code>
when I wanna add new String </p>
<p>elements.add("element");</p>
<p>with name which is my arraylist I wanna to automatically rename to _[a-z...] as windows rename file when there are two same... so for example I have in arraylist "element" when I add element again I wanna to rename automatically to element_a ... so </p>
<pre><code> if (elements.contains("element")) {
something
}
</code></pre>
<p>is there some function in java ?
thx for help</p>
| java | [1] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.