Unnamed: 0
int64
65
6.03M
Id
int64
66
6.03M
Title
stringlengths
10
191
input
stringlengths
23
4.18k
output
stringclasses
10 values
Tag_Number
stringclasses
10 values
2,057,497
2,057,498
ListView items won't show focus color when click
<p>When i click on listview, its not show the focus color .</p> <blockquote> <pre><code>&lt;ListView android:id="@+id/android:list" android:layout_width="fill_parent" android:layout_height="fill_parent" android:divider="@color/grey" android:dividerHeight="1px" android:drawSelectorOnTop="true" android:cacheColorHint="@android:color/transparent"/&gt; </code></pre> </blockquote>
android
[4]
2,955,260
2,955,261
Javascript random number picker not working
<p>I'm trying to make a simple javascript application to pick a random number between 1 and a number I specify in an input field, so I can pick a random winner for a Christmas competition. </p> <p>Below is the code I've got so far. I don't think it can be far off, can you help me as it's not updating the input field to display the random number:</p> <pre><code>&lt;script type="text/javascript" language="javascript"&gt; function randomWinner() { var topNumber = topNumber.value; var randomnumber=Math.floor(Math.random() + topNumber); winningNumber.value=randomnumber; return true; } &lt;/script&gt; &lt;form name="selectWinner"&gt; Pick random number between 1 and &lt;input name="topNumber" value="100"&gt;&lt;br /&gt;&lt;br /&gt; The winning number: &lt;input name="winningNumber" readonly="true"&gt;&lt;br /&gt;&lt;br /&gt; &lt;input type="button" value="Pick Winner" OnClick="randomWinner();"&gt; &lt;/form&gt; </code></pre>
javascript
[3]
5,160,014
5,160,015
Operator Overloading For Builtin Types
<p>How can I override operators to be used on builtin types like String, arrays etc? For example: I wish to override the meaining of the + operator for arrays.</p>
c#
[0]
4,479,396
4,479,397
multiplying two floats in C++ give me unknown results
<p>I am a C++ newbie and having a problem with my first program. I'm trying to multiply two float numbers and the result always show like 1.1111e+1 where 1s are the random numbers. Following is the little program I wrote.</p> <pre><code>#include &lt;iostream&gt; #include &lt;string&gt; #include &lt;conio.h&gt; using namespace std; int main() { float bank; float dollor; cout&lt;&lt;"Enter amount of $ deposited at Bank: ";//the data to input is 5000 cin&gt;&gt;bank; cout&lt;&lt;"Enter current $ price: ";//1usd = 800mmk: the data to input is 800 cin&gt;&gt;dollor; bank*=dollor;//all deposited $ to local currency cout&lt;&lt;"Result is "&lt;&lt;bank; getch(); } </code></pre> <p>and the result of this program is 4e+006.</p> <p>ps: I declared as float in order to input floats sometime. Please help me with this program where I was wrong. Thanks all..</p>
c++
[6]
3,705,356
3,705,357
What is this " var1 = Math.Ceiling(hours / (40.00M * 4.3M));"
<p>Anyone know what the C# "M" syntax means?</p> <pre><code>var1 = Math.Ceiling(hours / (40.00M * 4.3M)); </code></pre>
c#
[0]
229,922
229,923
Glow effect with background color using jQuery
<p>How can I add a subtle "glow" effect to a <code>div</code> element that will glow all the time/permanently, right after the page load, not just when hovered?</p> <p>Unfortunately, the client wants me to make this work in IE7+.</p>
jquery
[5]
2,685,362
2,685,363
Android: Implement Woopra in App
<p>Trying to add <strong>Woopra</strong> in my <code>Android</code> App but there is no <code>SDK</code> for <code>Android</code> provided. Is there any way to add <strong>Woopra</strong> in <code>Android App</code> to <code>log events</code>? Please help me on this if anybody have tried on this topic. thanks in advance. </p>
android
[4]
4,423,957
4,423,958
asp.net calling code inline not working
<p>In my code behind, I can do the following in the onload:</p> <pre><code>string x = Fmg.Cti.UI.Utilities.Classes.ResourceController.ReadResourceValue("Riblet", "Riblet_Chicklet1_Button_text"); </code></pre> <p>This works without issue.</p> <p>In my aspx page (I didn't remove the code from the onload), I put this:</p> <pre><code>&lt;%= Fmg.Cti.UI.Utilities.Classes.ResourceController.ReadResourceValue("Riblet", "Riblet_Chicklet1_Button_text")%&gt; </code></pre> <p>When I do, I got an error:</p> <blockquote> <p>error CS0234: The type or namespace name 'Cti' does not exist in the namespace 'Fmg' (are you missing an assembly reference?)</p> </blockquote> <p>I had this (or something quite similar) working. I don't know how I broke it.</p> <p>Thanks again for your help. </p>
asp.net
[9]
3,472,431
3,472,432
how to convert MID file to wav file?
<p>I want to play background music in my game application using AVAudio player.I am using .MDI file.This file is not playing in AVAudio player.So i want to convert this .MDi file to wav file.IS it possible?</p>
iphone
[8]
172,125
172,126
Understanding Python Numerology
<p>We can not declare an integer which start with 0.</p> <pre><code>&gt;&gt;&gt; n = 08 SyntaxError: invalid token </code></pre> <p>But we do declare a variable that contains all zeros.</p> <pre><code>&gt;&gt;&gt; n = 00000 &gt;&gt;&gt; print n &gt;&gt;&gt; 0 </code></pre> <p>So the question is in first case why python just not consider value of variable to <code>n = 8</code> by ignoring the zero on left side instead of raising an exception. As in second case it is still considering all zeros to a valid value.</p> <p>Consider another case.</p> <pre><code>&gt;&gt;&gt; n = '0008' &gt;&gt;&gt; print int(n) &gt;&gt;&gt; 8 </code></pre> <p>Now in third case it is still considering it a valid numeric value, why an exception is not raised here??</p>
python
[7]
2,086,656
2,086,657
C# - Static property in class
<p>I have the following code:</p> <pre><code> internal class ModuleLogic { #region [Private Variables] private static ReaderWriterLockSlim _moduleListLock = new ReaderWriterLockSlim(); private static List&lt;Module&gt; _moduleList; #endregion public static void RefreshModuleData() { _moduleListLock.EnterWriteLock(); try { ModuleData.RefreshModuleData(_moduleList); } finally { _moduleListLock.ExitWriteLock(); } } } </code></pre> <p>Am I correct that each time the RefreshModuleData() method is accessed, the two private static variables are shared for each access?</p>
c#
[0]
1,354,160
1,354,161
Removing HTML tags in PHP
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/6247035/strip-all-html-tags-except-allowed">Strip all HTML tags, except allowed</a> </p> </blockquote> <p>I'm new to PHP</p> <p>Here is my code </p> <pre><code>&lt;p&gt;The filetype you are attempting to upload is not allowed.&lt;/p&gt; </code></pre> <p>The expected output:</p> <pre><code>The filetype you are attempting to upload is not allowed. </code></pre> <p>How to remove the tags <code>&lt;p&gt;</code>?</p>
php
[2]
2,289,996
2,289,997
Show Rows based on values in multiple columns. JQuery
<p>In JQuery hiding a table row based on a predefined columns td value is easy using the following code.</p> <pre><code>function filterRows(word){ $('.application&gt;tbody&gt;tr') .show() .find('td:nth-child(2)').not(':contains("'+word+'")') .parent() .hide() } </code></pre> <p>However how would I go about showing rows that match td values in more than one column.</p> <p>Something like the following (which does not work)</p> <pre><code>function filterRows(word){ $('.application&gt;tbody&gt;tr') .show() .find('td:nth-child(2)').not(':contains("'+word+'")') .find('td:nth-child(3)').not(':contains(30)') .parent() .hide() } </code></pre> <p>Basically I want to be able to show only rows where my word is passed in "word" is in the second column td and the third column contains "30".</p> <p>Thanks for any heads up.</p>
jquery
[5]
5,578,007
5,578,008
A whole website with slide effect
<p>Does anybody know how can i achieve that "slider site" functionality like in here <a href="http://dawidtomczyk.pl/" rel="nofollow">http://dawidtomczyk.pl/</a></p> <p>Click on navigation home etc. </p> <p>After reviewing each of the plug-ins that was used along with that site, none of them where related to the "site slide" effect. After viewing the source code, I think He accomplished it with a custom function for that containing $(window).scroll() and i really didn't understand how I can accomplish that 'effect'.</p> <p>Also I would like to add that I prefer achieving it as much cross-browser as it can get. IE8+, and the new ones.</p> <p>Can it be done?</p>
jquery
[5]
372,597
372,598
CRC_CCITT Kermit 16 in C#
<p>I'm currently working on a hard way that requires the CRC_CCITT Kermit 16 protocol with the formula (X16 + X12 + X5 + 1). However some of the code I've found online both on this site or the web in general I don't seem to get my desired result. I saw this website (http://www.lammertbies.nl/comm/info/crc-calculation.html) that actually provides me with the exact match I want but it was written in C++. So can anyone help me with this? </p> <p>I look forward to hearing from you.</p> <p>Kind regards</p> <p>Michael</p>
c#
[0]
3,711,713
3,711,714
Rename Array Keys
<p>I need to change this array's keys to 0-5, why isn't this working?</p> <pre><code>$arr = array(); while(count($arr) &lt; 6){ $arr[] = rand(1,53); $arr = array_unique($arr); } asort($arr); $i = 0; foreach($arr as $key =&gt; $value){ //echo $i; $key = $i; $i++; } print '&lt;pre&gt;'; print_r($arr); </code></pre> <p>Thank you</p>
php
[2]
2,848,924
2,848,925
java.lang.UnsupportedClassVersionError:
<p>I have developed a small project in eclipse which makes use of Java6. But I want to run the same project in hpux system which has java1.5. When I try to run it is throwing the error : </p> <blockquote> <p>java.lang.UnsupportedClassVersionError:. </p> </blockquote> <p>Then I have changed the eclipse Java compiler to java1.5 and jre to 1.5.0_12 then recompiled my project. After that I have deployed once again in hpux system but still it is throwing the same error. I used ant to compile in hpux system. It compiled successfully and produced jar. But while running it is throwing the same error. </p> <p>Any help is highly appreciated. Many Thanks in Advance.</p>
java
[1]
5,415,934
5,415,935
Can I make a bitwise copy of a C++ object?
<p>Can C++ objects be copied using bitwise copy? I mean using memcopy_s? Is there a scenario in which that can go wrong?</p>
c++
[6]
4,046,797
4,046,798
A simple Thread scenario in Java where the Runnable interface need not be implemented by the Thread implementing class
<p>Let's look at the following code, it's working exactly.</p> <pre><code>final class DemoThread { public void temp() { new Thread(new Runnable() { public void run() { System.out.println( "Isn't it great ?" ) ; } } ) .start() ; } } final public class Main { public static void main(String[] args) { new DemoThread().temp(); } } </code></pre> <p>It works fine and displays the message <em>Isn't it great ?</em> on the console. The only question here is that why the Runnable interface need not be implemented by the class <strong>DemoThread</strong>?</p>
java
[1]
3,102,270
3,102,271
expected ';' before numeric constant
<p>I have the following code in C++, trying to write a xml file into a file, but it keeps giving me this problem "expected ';' before numeric constant</p> <pre><code>int main () { ofstream myfile; myfile.open ("example.xml", ios::out| ios::app| ios::binary); if (myfile.is_open()) { myfile &lt;&lt; "&lt;?xml version="1.0" encoding="UTF-8"?&gt; \n"; myfile &lt;&lt; "&lt;?xml-stylesheet type="text/xsl" href="wufi1d.xslt"?&gt; \n"; myfile &lt;&lt; "&lt;WUFI1D&gt; \n"; </code></pre> <p>Can anyone help?</p>
c++
[6]
4,688,109
4,688,110
Filemtime error
<p>Everything works fine when I try and do this.</p> <pre><code>echo date("F d, Y h:i:s A",filemtime("index.php")); </code></pre> <p>But when I try to run a code like this.</p> <pre><code>date_default_timezone_set('America/Chicago'); $name = $_SERVER['PHP_SELF']; $name = basename("$name", "").PHP_EOL; echo date("F d, Y h:i:s A",filemtime("$name")); </code></pre> <p>I get this garbage...</p> <pre><code>Warning: filemtime() [function.filemtime]: stat failed for index.php in C:\xampp\htdocs\newsite \footer.php on line 9 December 31, 1969 06:00:00 PM </code></pre> <p>I see no difference.</p>
php
[2]
482,620
482,621
How to fetch the data for PHP from two databases on different hosts and put them in a single html table?
<p>I have to put the data into a php page from the databases which are in seperate hosts. The one workaround i can think of is getting the data from both the databases onto an array and then displaying it. What if the array is multi dimensional? How to merge data from two databases on two different hosts in PHP? I am using PHP5.</p> <p>Specifics: I am working on a booking engine. There are booking pages for each state and databases for each of them on different hosts.I am working on creating a kind of summary page for staff, which shows the bookings done for all the states in a single page. They need it for internal use. The booking table in each of the database has same no.of rows. I need to know how merge the arrays obtained from these databases and then display it in a single web page.</p>
php
[2]
5,817,556
5,817,557
Is it possible to have a method act like a property in a javascript class?
<p>Take the following piece of javascript that is trying to implement a class:</p> <pre><code>function aClass(){ this.prop1 = this.getProp1(); } aClass.prototype.getProp1 = function(){ // do some stuff return result; } </code></pre> <p>I can then use it like so:</p> <pre><code>var obj = new aClass(); alert(obj.prop1); </code></pre> <p>What I now want to do is this:</p> <pre><code>obj.prop1 = "some value"; </code></pre> <p>This, of course overrides prop1, and I can no longer retrieve the generated result from the getProp1 function.</p> <p>So in short, is it possible to create a property that allows read and write, but instead calls a function in both cases for, say, validation purposes?</p> <p>I'm happy for a completely different approach to what I have here as long as I get the desired effect.</p> <p>It needs to work with older browsers.</p>
javascript
[3]
2,920,176
2,920,177
Adding timestamps together to get total hours and minutes
<p>I am trying to write a function that will add time stamps together to get a sum of all. For example:<code>11:30 + 12:00 + 15:35 = 39:05</code> I am unsure of how to accomplish this. I have included code below that I have tried but it does not give the desired result:</p> <pre><code>$TotalTime = strtotime($data['TotalSunday']) + strtotime($data['TotalMonday']) + strtotime($data['TotalTuesday']) + strtotime($data['TotalWednesday']) + strtotime($data['TotalThursday']) + strtotime($data['TotalFriday']) + strtotime($data['TotalSaturday']); $data['TotalTime'] = gmdate("h:i", $TotalTime); </code></pre>
php
[2]
4,746,952
4,746,953
Loop every 10 second
<p>How to load a loop every 10 second and add +1 to the count and print it?</p> <p>like:</p> <pre><code>int count; while(true) { count +=1; cout &lt;&lt; count &lt;&lt; endl; // print every 10 second } </code></pre> <p>print:</p> <pre><code>1 2 3 4 5 ect... </code></pre> <p>i dont know how, please help me out guys</p>
c++
[6]
4,225,509
4,225,510
Best way to get only certain groupings out of a string
<p>I am getting a list of file names using the following code: </p> <pre><code> //Set up Datatable dtUpgradeFileInfo.Columns.Add("BaseFW"); dtUpgradeFileInfo.Columns.Add("ActiveFW"); dtUpgradeFileInfo.Columns.Add("UpgradeFW"); dtUpgradeFileInfo.Columns.Add("FileName"); //Gets Upgrade information and upgrade Files from Upgrade Folder DirectoryInfo di = new DirectoryInfo(g_strAppPath + "\\Update Files"); FileInfo[] rgFiles = di.GetFiles("*.txt"); foreach (FileInfo fi in rgFiles) { test1 = fi.Name.ToString(); } </code></pre> <p>All file names will be in the form BXXXX_AXXXX_UXXXX. Where of course the Xs represent a number 0-9, and i need those 3 grouping of just numbers to put each into their respective column in the Datatable. I was initially intending to get the characters that represent each grouping and putting them together for each grouping but i'm wondering if there is a better way/quicker way than sending it to a charArray. Any suggestions?</p>
c#
[0]
3,444,091
3,444,092
how to get text from multiple edit text with the same id in android
<p>I am creating an edit text filed using xml and adding that in listview 's adapter class .i m using enumerator.by this i was able to create two textfields with the same id.the problem is how to get the strings from both the text fields since they are sharing the same id.below is the code.</p> <pre><code>@Override public View getView(final int position, View convertView, ViewGroup parent) { View rowView = null; AddKeywordRow row = keywordRows.get(position); switch (row.getRowType()) { case TitleRow: rowView = inflater.inflate(R.layout.titlerow, null); TextView txtTitle = (TextView) rowView.findViewById(R.id.rowtitle); txtTitle.setText(row.getMessage()); break; case EditRow: rowView = inflater.inflate(R.layout.editrow, null); txtInput = (EditText) rowView.findViewById(R.id.rowedit); txtInput.setHint(row.getMessage()); if (row.getHeight() != 0) { LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT,row.getHeight()); txtInput.setLayoutParams(layoutParams); layoutParams.setMargins(7, 0, 7,0); //txtInput.setLayoutParams(new LinearLayout.LayoutParams( // LinearLayout.LayoutParams.MATCH_PARENT, row.getHeight())); txtInput.setPadding(3,0,0,30); } // set padding and margin break; case MessageRow: rowView = inflater.inflate(R.layout.messagerow, null); TextView txtMessage = (TextView) rowView .findViewById(R.id.rowmessage); txtMessage.setText(row.getMessage()); break; case ButtonRow: rowView = inflater.inflate(R.layout.buttonrow, null); Button btn = (Button)rowView.findViewById(R.id.button1); btn.setOnClickListener(new OnClickListener() { } }); break; } return rowView; } </code></pre>
android
[4]
4,647,299
4,647,300
Why does the MSDN site compare using delegates and interfaces?
<p>The MSDN site compares using delegates instead of an interface, but what makes these two language-level constructs so similar that one could be used over another? They seem to do completely different things?</p> <p>Thanks</p>
c#
[0]
5,622,845
5,622,846
How would one implement a NumberPicker in Android API 7?
<p>There's a NumberPicker widget in API 11, but I'm building for a minimum API of 7. How would I go about implementing one? Is there a custom widget that I can use, or is there a way to get at the components that make up DatePicker / TimePicker?</p>
android
[4]
3,853,525
3,853,526
Pass a function by reference in PHP
<p>Is it possible to pass functions by reference?</p> <p>Something like this:</p> <pre><code>function call($func){ $func(); } function test(){ echo "hello world!"; } call(test); </code></pre> <p>I know that you could do <code>'test'</code>, but I don't really want that, as I need to pass the function by reference.</p> <p>Is the only way to do so via anonymous functions?</p> <p>Clarification: If you recall from C++, you could pass a function via pointers:</p> <pre><code>void call(void (*func)(void)){ func(); } </code></pre> <p>Or in Python:</p> <pre><code>def call(func): func() </code></pre> <p>That's what i'm trying to accomplish. </p>
php
[2]
2,496,423
2,496,424
Adding Filters to List
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/3838845/jquery-remove-duplicate-li">jquery remove duplicate li</a> </p> </blockquote> <p>I have a List which looks like the following: <a href="http://jsfiddle.net/UwPTF/" rel="nofollow">http://jsfiddle.net/UwPTF/</a></p> <pre><code>&lt;ul class="uol"&gt; &lt;li&gt;beta&lt;/li&gt; &lt;li&gt;gamma&lt;/li&gt; &lt;li&gt;alpha&lt;/li&gt; &lt;li&gt;beta&lt;/li&gt; &lt;li&gt;zeta&lt;/li&gt; &lt;li&gt;BETA&lt;/li&gt; &lt;/ul&gt; </code></pre> <p>I have 2 buttons, one to highlight the items that are duplicate and the other to remove the duplicate items. </p> <p>I am trying to use the filter function. If you can explain your code, it's highly appreciated.</p>
jquery
[5]
4,757,164
4,757,165
check if any select box has changed after button click
<p>I want to check a group of select boxes and see if they changed after a button has clicked.</p> <pre><code>&lt;select name="data[model][that]" class="location_dropdown"&gt; &lt;option value="value1"&gt;value 1&lt;/option&gt; &lt;option value="value2"&gt;value 2&lt;/option&gt; &lt;option value="value3" selected="selected"&gt;value 3&lt;/option&gt; &lt;/select&gt; &lt;select name="data[model][that]" class="location_dropdown"&gt; &lt;option value="value1"&gt;value 1&lt;/option&gt; &lt;option value="value2" selected="selected"&gt;value 2&lt;/option&gt; &lt;option value="value3"&gt;value 3&lt;/option&gt; &lt;/select&gt; &lt;select name="data[model][other]" class="location_dropdown"&gt; &lt;option value="value1" selected="selected"&gt;value 1&lt;/option&gt; &lt;option value="value2"&gt;value 2&lt;/option&gt; &lt;option value="value3"&gt;value 3&lt;/option&gt; &lt;/select&gt; $(document).ready(function() { $('#update-selected-btn').click(function(){ $('.location_dropdown').each(function(){ }); }); if state hasnt changed on any drop downs alert("nothing selected") }); </code></pre> <p>Obviously cant use onchange as I want to check for change when button click triggered. I was thinking about maybe building a array of values and checking them against each other, but wonder if there is another solution.</p> <p><strong>UPDATE:</strong></p> <p>I did attempt this, but syntax isnt right.</p> <pre><code>$('.location_dropdown').each(function(){ if ($(this + " option:selected").prop('selected') == 'selected'){ changed++; } }); </code></pre>
jquery
[5]
5,962,925
5,962,926
I cant make the exe setup file in c#
<p>I have the solution bar in visual studio 2008 from c# but i can my project make a exe setup file becouse it have the solution bar but havent that solution fanction so how to get that function?</p>
c#
[0]
4,909,309
4,909,310
How to customize the color of the CheckMark color in android in a dialog. : android
<p>How to customize the color of the CheckMark color in android in a dialog. Currently , By default, the color of the checkmark is green by default. I would like to customize it to a different color of choice</p>
android
[4]
2,411,785
2,411,786
PackageManager not showing installed Live Wallpapers
<p>I am trying to load a list of all installed packages on the device, however, when I do this, any installed Live Wallpapers do not show up on the list... is there a way to fix this?</p> <p>Here's my code:</p> <pre><code>final PackageManager pm = this.getPackageManager(); Intent intent = new Intent(Intent.ACTION_MAIN, null); intent.addCategory(Intent.CATEGORY_LAUNCHER); final ArrayList&lt;ResolveInfo&gt; list = (ArrayList&lt;ResolveInfo&gt;) pm.queryIntentActivities(intent, PackageManager.PERMISSION_GRANTED); for (ResolveInfo rInfo : list) { Log.i(TAG, ": Installed Applications " + rInfo.activityInfo. applicationInfo.loadLabel(pm).toString()); } final ArrayAdapter&lt;ResolveInfo&gt; adapter = new ArrayAdapter&lt;ResolveInfo&gt;(this, R.layout.list_item, list) { @Override public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) convertView = LayoutInflater.from(parent.getContext()). inflate(R.layout.list_item, parent, false); final String text = list.get(position).activityInfo. applicationInfo.loadLabel(pm).toString(); ((TextView)convertView.findViewById(R.id.text)).setText(text); final Drawable drawable = list.get(position).activityInfo.applicationInfo.loadIcon(pm); ((ImageView)convertView.findViewById(R.id.image)).setImageDrawable(drawable); return convertView; } }; setListAdapter(adapter); ListView lv = getListView(); lv.setTextFilterEnabled(true); </code></pre>
android
[4]
1,168,854
1,168,855
Open page in window of specific size
<p>The following Javascript opens a window as required in IE8, FF4 and Safari 5.0.5 but not in Opera or Chrome.</p> <pre><code>function setWindowSize(){ var window_height = 600; var window_width = 600; window.resizeTo(window_width, window_height); } </code></pre> <p>I would like a jQuery script that does the same, and hopefully does so in both Opera and Chrome.</p> <p>Should not be too difficult, but it's got me beaten.</p>
jquery
[5]
880,027
880,028
substitute of function pointers in python
<p>I have worked in low level C programming for years and I don't have enough exposure to Object oriented approaches. In C if I was developing some layered architecture then each layer has interfaces defined by function pointers. The advantage of that the whole layer can be replaced by just setting those function pointers at initialization to another layer. </p> <p>I want the same thing but this time in Python. What is the coolest way to achieve that. To give a little background to my problem, I have a data generator which can output records to different mediums. The medium is specified at the configuration time. I don't want to use if or switch statements here. The best way was to use function pointers in C but what are the options available here in Python. Any Object oriented approaches are also appreciated.</p> <p>Thanks</p>
python
[7]
333,311
333,312
How to check if an element of a list is a list (in Python)?
<p>If we have the following list:</p> <pre><code>list = ['UMM', 'Uma', ['Ulaster','Ulter']] </code></pre> <p>If I need to find out if an element in the list is itself a list, what can I replace <em>aValidList</em> in the following code with?</p> <pre><code>for e in list: if e == aValidList: return True </code></pre> <p>Is there a special import to use? Is there a best way of checking if a variable/element is a list?</p>
python
[7]
4,609,435
4,609,436
URL encoding for multibyte character string in c++
<p>I am trying to achieve URL encoding for some of my strings via c++. Strings can contaim multibyte characters like ™, ®, ©, etc.</p> <p><strong>Input text</strong>: Something ™ <br /> <strong>Output should be</strong>: Something%20%E2%84%A2</p> <p>I can achieve URL encode or decode in JS with encodeURIComponent and decodeURIComponent, but I have some native code in c++ and hence need to encode some text via c++.</p> <p>Any help here would be great relief for me.</p>
c++
[6]
5,477,166
5,477,167
jquery option text selector problem
<pre><code>&lt;select id="name"&gt; &lt;option value="1005"&gt;peter&lt;/option&gt; &lt;option value="2056" selected="selected"&gt;shan&lt;/option&gt; &lt;/select&gt; </code></pre> <p>how to set option's text=peter selected?<br> like this <code>$('#name option[text=peter]').attr('selected',true)</code>;</p>
jquery
[5]
5,951,340
5,951,341
network provider not working in android
<p>i have to make an android application in which i need to find the current location of the user. For this i am first using the GPS provider, but if it is not available i fall back to the network provider. Now there have been instances on my phone when even the network provider is not working and the statement network_enabled = lm .isProviderEnabled(LocationManager.NETWORK_PROVIDER);</p> <p>is giving a false value. </p> <p><strong>My question</strong></p> <p>i am still able to make calls from my phone, so my network provider is working fine. what i need to know is in what conditions does the network provider not work? what could be the possible scenarios where the network provider on my android device not work to supply me my co-ordinates.</p> <p>thank you in advance</p>
android
[4]
4,817,895
4,817,896
Every keypress insert a character into a hidden text input
<p>I am trying to insert a specific character say the letter "H" every time a key is pressed in another text box.</p> <p>Eg. </p> <p>Text box 1: Type your name <br>Text box 2: HHHHHHHHHHHHHH</p> <p>I have tried</p> <pre><code>$('#cartText16132').keyup( function() { $('input#test').val('1'); }); </code></pre> <p>But that only inserts one "1"</p> <p>Hope that makes sense.</p>
jquery
[5]
4,736,788
4,736,789
Launching application on call
<p>I am new to iphone application. I am creating a new application which should work in background and activate when call comes. I understand truecaller works in similar way. </p> <p>Thank You</p>
iphone
[8]
5,815,799
5,815,800
strange Fatal error: Cannot redeclare class paradox
<p>I get the following error:</p> <pre><code>Fatal error: Class 'mysql' not found in /home/o </code></pre> <p>So naturally I include the class, but when I do I get this error:</p> <pre><code>Fatal error: Cannot redeclare class </code></pre> <p>As you can imagine I have no idea how to fix this problem!!</p> <p>Any ideas?</p>
php
[2]
2,755,390
2,755,391
PHP encrypt password before storing it to database
<p>I found the following example on php.net to secure password before storing it. However, I don't quite understand line 3. Could someone explain this a little bit? Thanks! </p> <pre><code>1 &lt;?php 2 $password = crypt('mypassword'); // let the salt be automatically generated 3 if (crypt($user_input, $password) == $password) { 4 echo "Password verified!"; 5 } 6 ?&gt; </code></pre>
php
[2]
2,103,676
2,103,677
Unknown file type error with .pyx file
<p>I'm trying to build a Python package (pyregion) that contains a *.pyx file and error comes during the build process. Checking out the below output:</p> <pre><code>$ python setup.py build running build running build_py creating build creating build/lib.macosx-10.5-x86_64-2.7 .... running build_ext building 'pyregion._region_filter' extension C compiler: gcc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -DNDEBUG -g -O3 -arch x86_64 error: unknown file type '.pyx' (from 'src/_region_filter.pyx') </code></pre> <p>Any ideas on what the issue could be? Just to note, I'm using the Enthought build of Python (7.1) on OSX with the latest Xcode (4.1). </p> <p>Cheers </p>
python
[7]
4,135,126
4,135,127
what is new in AVD 2.3 to compare 2.1
<p>i want to know that which are new features in 2.3 compare 2.1.<br> i have hndled many project in android in 2.1 and good experiance. please list out what's new feature in 2.3.</p>
android
[4]
3,579,207
3,579,208
Imput console commands through a desktop app get returned rows back?
<p>What I am trying to do is to imput console comands on a desktop app(in a textBox) click a button, execute the command and get the returned values back for display..</p> <p>The point is, I want to make my work faster and less stresful when trying to imput repetitive commands on the console over and over again everyday..</p> <p>I know some console application programming on c# and web applications(.net,ADO.NET) on c# aswell..but nothing about desktop applications..any help? Thanks!</p>
c#
[0]
2,477,437
2,477,438
Random in python 2.5 not working?
<p>I am trying to use the import random statement in python, but it doesn't appear to have any methods in it to use.</p> <p>Am I missing something?</p>
python
[7]
1,947,094
1,947,095
calling a function from another function by 'onclick' event
<p>What I am trying to do is, call a function from another function by clicking a radio button in that function. Here is the code I have worked on so far-</p> <pre><code>&lt;script type="text/javascript"&gt; rad1 = document.createElement("input"); rad1.type = "radio"; rad1.name = "dooropt"; rad1.id = "rb1"; rad1.value = "y"; newP.appendChild(rad1); text1 = document.createTextNode("Yes "); newP.appendChild(text1); rad2 = document.createElement("input"); rad2.type = "radio"; rad2.name = "dooropt"; rad2.id = "rb2"; rad2.value = "n"; newP.appendChild(rad2); text2 = document.createTextNode("No "); newP.appendChild(text2); button1 = document.createElement("input"); button1.type = "button"; button1.value = "Open main door"; button1.style.visibility = "hidden"; newP.appendChild(button1); button2 = document.createElement("input"); button2.type = "button"; button2.value = "Open apartment door"; button2.style.visibility = "hidden"; newP.appendChild(button2); area.appendChild(newP); rad1.onclick = mainalso(); rad2.onclick = onlyapp(); } function mainalso() { button1.style.visibility="visible"; button2.style.visibility="visible"; } function onlyapp() { button2.style.visibility="visible"; button1.style.visibility="hidden"; } &lt;/script&gt; </code></pre> <p>Now, whenever rad1 is clicked, i want mainalso() to run, as might be clear from the code. Since I am fairly new to JavaScript, I don't know where i'm making the mistake, in syntax or conceptually. Also, the first function (before mainalso()) is add(), and in it I repeatedly append same content on clicking a button in my body. I hope it is clear what I want to do. When rad1 is clicked, i want both buttons (button1 and button2) to appear, but on clicking rad2 I want only one button to appear. Both have been set to 'hidden' visibility at first. Please help me out. Sorry if it seems unclear, I tried my best.. Thank you.</p>
javascript
[3]
3,556,513
3,556,514
Add Variable to $_SERVER array via php.ini
<p>I need to add a variable to the $_SERVER array in a php script. Is there a possibility to do this via the php.ini file? I want to add the variable for all scripts on the webserver, so it's quite inconvenient to add it in each script.</p> <p>Thanks, TSS</p>
php
[2]
391,714
391,715
What is the issue with this java singleton class implementation?
<p>I have come across another article in stackexchange on various ways to implement java singleton. One of the ways shown is the following example. It has been voted very low. Wanted to understand why. <a href="http://stackoverflow.com/questions/70689/what-is-an-efficient-way-to-implement-a-singleton-pattern-in-java">What is an efficient way to implement a singleton pattern in Java?</a></p> <pre><code>public class Singleton { private static Singleton instance = null; static { instance = new Singleton(); // do some of your instantiation stuff here } private Singleton() { if(instance!=null) { throw new ErrorYouWant("Singleton double-instantiation, should never happen!"); } } public static getSingleton() { return instance; } } </code></pre>
java
[1]
5,063,855
5,063,856
Getting one line in a huge file with PHP
<p>How can i get a particular line in a 3 gig text file. The lines are delimited by \n. And i need to be able to get any line on demand.</p> <p>How can this be done? Only one line need be returned. And i would not like to use any system calls.</p> <p>Note: There is the same question elsewhere regarding how to do this in bash. I would like to compare it with the PHP equiv. </p> <p><strong>Update:</strong> Each line is the same length the whole way thru.</p>
php
[2]
5,336,089
5,336,090
Improving Collections.Sort
<p>I am sorting 1 million strings (each string 50 chars) in ArrayList with</p> <pre><code>final Comparator comparator= new Comparator&lt;String&gt;() { public int compare(String s1, String s2) { if (s2 == null || s1 == null) return 0; return s1.compareTo(s2); } }; Collections.Sort(list,comparator); </code></pre> <p>The average time for this is: 1300 millisec</p> <p>How can I speed it up? </p>
java
[1]
2,116,251
2,116,252
python .os.path.walk with direct file
<p>Everything in the <code>/home/username/main/books/</code> directory gets written and returned, but <code>/home/username/main/index.html</code> does not get written because "index.html" is not a directory and therefore cannot be walked. How would I revise the script to say if its a directory, walk it then write everything it finds, and if its direct file, write it.</p> <p>python</p> <pre><code>def zipit (request): file_paths = ['/home/username/main/books/', '/home/username/main/index.html'] buffer= StringIO.StringIO() z= zipfile.ZipFile( buffer, "w" ) for p in file_paths: for dir, subdirs, files in os.walk(p): for f in files: filename = os.path.join(dir, f) z.write(filename, arcname = filename[15:]) z.close() buffer.seek(0) final = HttpResponse(buffer.read()) final['Content-Disposition'] = 'attachment; filename=dbs_custom_library.zip' final['Content-Type'] = 'application/x-zip' return final </code></pre>
python
[7]
1,501,299
1,501,300
native iphone graphing library?
<p>Does anyone know of a native graphing library for the iPhone SDK? I have a free iPhone polling app called Show of Hands that currently uses calls to google charts via embedded safari pages, e.g. <a href="http://www.showofhands.mobi/Viewmore.aspx?qid=9245968c-d40d-478c-8781-804d086cd643" rel="nofollow">http://www.showofhands.mobi/Viewmore.aspx?qid=9245968c-d40d-478c-8781-804d086cd643</a> . Pros: free and easy and web-accessible. Cons: slower and less flexible within the app than native. So...I'm exploring options for handling the graphing and mapping functionality natively, without needing to roll my own. </p> <p>Any suggestions?</p> <p>Thanks!!</p> <p>-tony</p>
iphone
[8]
4,668,037
4,668,038
throwable will not compile
<p>First I must say that I read the following: <a href="http://docs.oracle.com/javase/tutorial/essential/exceptions/index.html" rel="nofollow">http://docs.oracle.com/javase/tutorial/essential/exceptions/index.html</a>!</p> <p>The error I get when I try to compile is the following:</p> <pre class="lang-none prettyprint-override"><code>TestException.java:14: error: incompatible types static void doRisky(String test) throws ScaryException ^ required: Throwable found: ScaryException TestException.java:19: error: incompatible types throw new ScaryException(); ^ required: Throwable found: ScaryException TestException.java:34: error: incompatible types catch ( ScaryException se) ^ required: Throwable found: ScaryException 3 errors </code></pre> <p>I'm assuming that the error message is giving me some type of hint, but I just don't see what it is.</p> <pre><code>import java.lang.*; /** add this as to get it to compile */ class ScaryException extends Exception { /** how come I can't put code here? */ } public class TestException { static void doRisky(String test) throws ScaryException{ System.out.println ("start risky"); if ("yes".equals(test)) { throw new ScaryException(); } System.out.println("end risky"); } public static void main(String [] args){ String test = "no"; try{ System.out.println("start try"); doRisky(test); doRisky("yes"); System.out.println("end try"); } catch ( ScaryException se){ System.out.println("Got What " + se); } finally{ System. out. println( "finally") ; } System.out.println("end of main"); } } </code></pre>
java
[1]
3,976,718
3,976,719
How to overwrite the mapview over pdf file in iphone?
<p>I need to insert the .pdf file into app and i need to set gps over it?That pdf file has to work as map?</p>
iphone
[8]
3,852,401
3,852,402
What's wrong with Java?
<p>I regularly see/hear negative comments about Java, but there never seems to be any specific negative point about it, at least nothing that hasn't been addressed in later versions.</p> <p>So, really, what's wrong with Java?</p>
java
[1]
153,650
153,651
Insert & Symbol in Textview android:text
<p>How can i insert <code>&amp;</code> Symbol in <code>&lt;TextView&gt;</code><br> i have tried with &amp; and Hex code but not allow me to do this. </p> <pre><code> &lt;TextView android:layout_height="wrap_content" android:textColor="#49515F" android:text="Mission and Philosophy" // &amp; android:textStyle="bold" android:textSize="11dp" android:layout_width="wrap_content" /&gt; </code></pre>
android
[4]
4,263,108
4,263,109
AddDays() not working within a while loop
<p>Is there anything that stops the <code>DateTime AddDays()</code> method that doesn't run within a while loop. I have this simple bit of code;</p> <pre><code>DateTime last_day = monthCalendar2.SelectionRange.End; DateTime first_day = new DateTime(year, month, day); //Insert dates into vector while (first_day != last_day) { dates.Add(first_day); first_day.AddDays(1); } </code></pre> <p>I step through the program and first_day never changes, anyone know why?!</p>
c#
[0]
5,431,434
5,431,435
How to detect Android version and brand from webkit browser?
<p>How to detect Android version and brand via webkit browser and is it reliable?</p>
android
[4]
1,863,420
1,863,421
What happens when I give more parameters than required in the function in Javascript?
<p>Assume - </p> <pre><code>function noname(a, b) { //code } </code></pre> <p>and I give - </p> <pre><code>noname(4,5,6,7); </code></pre> <p>What will happen then?</p>
javascript
[3]
135,466
135,467
No network access when debugging on Droid X
<p>I just picked up a used Droid X for development and when I try to debug from eclipse I don't have any network access. Works fine when I run the app non-debug. I've installed the Moto USB drivers for Windows and I've tried all the USB connection types on the phone and before you ask, yes USB debugging is turned on. I can step through the code and such, just no network access.</p> <p>Anyone else see this problem? Any solution?</p>
android
[4]
5,317,152
5,317,153
Printing results immediately (php)
<p>I have a php script that connects 10 different servers to get data. I want it to print the results of the 1st connection before the second one begins. </p>
php
[2]
4,421,001
4,421,002
Trying to isolate certain array items and evaluate them for equality
<p>I've got an fstream input file that has [N] lines or items. I've written code to decide which items are triangles and which are rectangles and which are circles. I've got to isolate just the triangle items and then compare them to see if they are equal to +/- 0.1 the area of all the other triangle items. Then I have to cout the equal pairs of items as uppercase char letters. </p> <p>Here's my code so far but it's not working correctly. It's giving me the last item in the array plus one that doesn't exist. How do I fix this?</p> <pre><code>// ........................................................ // 4. List any triangular blocks that are the same size. // ........................................................ float TAE = 0.0; float ItmM = 0.0; for (int i=0; i&lt;M; i++) { if (btype[i] == Triangles) { TA[i] = (0.5 * (D[i] * E[i])); TAE = TA[i+1]; if ((TA[i] - 0.1) &lt;= TAE &lt;= (TA[i] + 0.1)) { TAE = TA[i]; ItmN = i; ItmM = i+1; } } } cout &lt;&lt; "4. Triangular blocks that are the same size = " &lt;&lt; (char)('A' + ItmN) &lt;&lt; "&amp;" &lt;&lt; (char)('A' + ItmM) &lt;&lt; endl; </code></pre>
c++
[6]
1,986,120
1,986,121
Best Way To Determine If ReportViewer Is Installed using C#
<p>What is the best way to find out if reportviewer and WindowsInstaller-KB893803-v2-x86 is installed on a pc? Is there a way to find out what public key to use to find out if a specific program is installed on a pc? <a href="http://blogs.msdn.com/b/wriju/archive/2008/07/01/how-to-find-public-key-token-for-a-net-dll-or-assembly.aspx" rel="nofollow">(Tried this, didnt work)</a></p> <p><a href="http://stackoverflow.com/questions/16178/best-way-to-determine-if-net-3-5-is-installed">Best Way To Determine If .NET 3.5 Is Installed</a> This is how to check if .NET 3.5 is installed, but i take it you need a another public key to know if report viewer is installed, but i dont know how to get the public key.</p> <p>All i can think of is to check if the installation directory exists on the computer, would that be an acceptable way to check?</p>
c#
[0]
4,811,123
4,811,124
Crash when calling stringByEvaluatingJavaScriptFromString on UIWebView from button
<p>I can't find any documentation to confirm this, but it appears that you can only call the method <strong>stringByEvaluatingJavaScriptFromString</strong> in overridden methods from a UIWebView delegate. Can anyone confirm this?</p> <p>Here's what I've tried. I setup a button on a view, link it to a method on my viewcontroller, and make sure it works fine. My view has a UIWebView control on it as well. If I run the project on the simulator or on the iPhone, there are no issues. Then I add this code to the button's method.</p> <pre><code>[theWebView stringByEvaluatingJavaScriptFromString:@"alert('Hi there!');"]; </code></pre> <p>When I run the project, I can click the button and see the 'Hi there' prompt and I can click OK to dismiss it. Usually 4-5 seconds later the simulator crashes. I occasionally see the <code>"__TERMINATING_DUE_TO_UNCAUGHT_EXCEPTION__"</code> error, but not consistently; sometimes there's no error. It also doesn't always crash the first time. Sometimes I go to another page, and then try it again, and it crashes.</p> <p>If I put the same code in the webPageDidFinishLoad event it works fine. But I'd like the code to be called when the user demands it so that event doesn't suit my needs.</p> <p>I'm open to a workaround if you have any ideas? Thanks in advance!</p>
iphone
[8]
532,059
532,060
TimePickerListener calling two methods for same time
<p>Hi please find the below code I am facing issue with Time dialog listener method, It's calling two times listener.How to fix the listener one time.</p> <pre><code>@Override protected Dialog onCreateDialog(int id) { switch (id) { case TIME_DIALOG_ID: // set time picker as current time return new TimePickerDialog(this, timePickerListener, hour, minute, false); } return null; } private TimePickerDialog.OnTimeSetListener timePickerListener = new TimePickerDialog.OnTimeSetListener() { public void onTimeSet(TimePicker view, int selectedHour, int selectedMinute) { System.out.println("=========Dialog=================="); hour = selectedHour; minute = selectedMinute; // set current time into textview tvDisplayTime.setText(new StringBuilder().append(pad(hour)) .append(":").append(pad(minute))); // set current time into timepicker timePicker1.setCurrentHour(hour); timePicker1.setCurrentMinute(minute); } }; private static String pad(int c) { if (c &gt;= 10) return String.valueOf(c); else return "0" + String.valueOf(c); } </code></pre> <p>Please help me for call listener one time, I am refering this URL: <a href="http://www.mkyong.com/android/android-date-picker-example/" rel="nofollow">http://www.mkyong.com/android/android-date-picker-example/</a></p> <p>I am using emulator version 4.1 .</p>
android
[4]
4,323,890
4,323,891
I have a jquery question,chould you help me?
<pre><code>&lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(document).ready(function(){ var $category = $("ul li:gt(5):not(:last)"); $category.hide(); $("input").click(function(){ if($category.is(":visiable")){ $category.hide(); $("input").attr("value","精简显示") } else{ $category.show(); $("input").attr("value","全部显示") } }) }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div class="category"&gt; &lt;ul&gt; &lt;li&gt;苹果&lt;/li&gt; &lt;li&gt;诺基亚&lt;/li&gt; &lt;li&gt;摩托罗拉&lt;/li&gt; &lt;li&gt;索爱&lt;/li&gt; &lt;li&gt;三星&lt;/li&gt; &lt;li&gt;LG&lt;/li&gt; &lt;li&gt;黑莓&lt;/li&gt; &lt;li&gt;多普达&lt;/li&gt; &lt;li&gt;西门子&lt;/li&gt; &lt;li&gt;魅族&lt;/li&gt; &lt;li&gt;其他品牌&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;div class="more"&gt;&lt;input type="button" value="全部显示"&gt;&lt;/div&gt; </code></pre> <p>The code is error,but I don't know what wrong is,chould you help me?</p>
jquery
[5]
3,291,782
3,291,783
Programmatically creating variables in Python
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/1429814/how-to-programmatically-set-a-global-module-variable">How to programmatically set a global (module) variable?</a> </p> </blockquote> <p>I have a class called Variable defined as so:</p> <pre><code>class Variable(): def __init__(self, name): self.name = name self._value = None def value(self): return self._value def __repr__(self): return self.name </code></pre> <p>I want to create 26 capital single letter instances of Variable like this:</p> <pre><code>A = Variable('A') B = Variable('B') ... Z = Variable('Z') </code></pre> <p>So far I've tried various solutions, and the best I've come up with is:</p> <pre><code>from string import uppercase for char in uppercase: exec "%s = %s" % (char, Variable(str(char))) in None </code></pre> <p>However, this doesn't run and gives me this error:</p> <pre><code>Traceback (most recent call last): File "C:\Users\Administrator\Dev\python\truthtable\truthtable.py", line 7, in &lt;module&gt; exec "%s = %s" % (char, Variable(str(char))) in None File "&lt;string&gt;", line 1, in &lt;module&gt; NameError: name 'A' is not defined </code></pre> <p>What am I doing wrong?</p>
python
[7]
3,333,301
3,333,302
can jquery append an image in input part?
<p>I want to peend an image in input part.(in the input box, after the value word) Can jquery do that? Thanks.</p> <pre><code>$("#click").click(function(){ $("#text").append("&lt;img class='loading' src='load.gif'/&gt;"); ... }); &lt;form name="form"&gt; &lt;input type="text" id="text"&gt; &lt;a id="click"&gt;search&lt;/a&gt; &lt;/form&gt; </code></pre>
jquery
[5]
4,307,536
4,307,537
Create an RSS feed from Existing RSS
<p>Im using the Twitter API to read the Favorites RSS, it generates the following output: </p> <p><a href="http://vl3.co.uk/favs/getfavs.php" rel="nofollow">http://vl3.co.uk/favs/getfavs.php</a></p> <p>I'm not sure why this file seems to be incorrect, doesnt come up in my RSS reader or render correctly in the browser. Can anyone shed any light on this?</p> <p>If the output is not valid RSS how can I make it so?</p> <p>Secondly I'd like to cache the RSS feed to then use something like Magpie RSS Parser.</p>
php
[2]
1,512,921
1,512,922
Derive window.self from object
<p>is there a way to get window.self of an unknown iframe (same domain) with the only reference: an object within the iframe (a div). holding thumbs for this one</p>
javascript
[3]
5,028,052
5,028,053
Android - How to create a control to pick a contact from my phones contact?
<p>I want to create a control on a user form so that whenever i click on it, my phones contact list is shown with Search , indexing and grouping functionality same as android contact application and i would pick any contact and return to my form. </p>
android
[4]
276,046
276,047
Compilation error while compiling 2.1.2 code on 3.0 iphone SDK
<p>When I'm trying to compile 2.1.2 SDK code on 3.0 or higher version, it gives a compilation error saying "CFXMLTreeRef undeclared identifier". Below is the code snippet where it shows the error:</p> <pre><code>#ifdef TARGET_IPHONE_SIMULATOR #import &lt;CoreServices/CoreServices.h&gt; //cause of the preoblem #else #import &lt;CFNetwork/CFNetwork.h&gt; #endif </code></pre> <p>I searched for the "CFXMLTreeRef" in 2.1.2 SDK and it's found, but in SDK version higher than 3.0, I couldn't find it.</p> <p>Can anyone tell where can I find the declartion of "CFXMLTreeRef".</p> <p>I would really appreciate any help.</p> <p>Thanks Puru</p>
iphone
[8]
5,446,167
5,446,168
undefined reference to `elast_opt()' collect2: ld returned 1 exit status
<p>I've written some oop code that use dealii library.</p> <p>class <code>elastic</code> is defined in prelim header as:</p> <pre><code>using namespace dealii; template &lt;int dim&gt; class elastic { public: elastic(const Triangulation&lt;dim&gt; *triang); ~elastic() ; void run() ; private: . . . </code></pre> <p>and in another header that includes header:</p> <pre><code>template &lt;int dim&gt; elastic&lt;dim&gt;::elastic(const Triangulation&lt;dim&gt; *triang): dof_handler (triangulation), fe (FE_Q&lt;dim&gt;(1)) {triangulation.copy_triangulation (*triang);} </code></pre> <p>and my main is written below:</p> <pre><code>#include "prelim.h" using namespace dealii; int main() { deallog.depth_console (0); elastic&lt;2&gt; *elast_opt(); for ( iter=0; iter&lt;5 ; ++iter) elast_opt()-&gt;run(); return 0; } </code></pre> <p>When I compile I get these errors:</p> <pre><code>....../main.cc:16: undefined reference to `elast_opt()' collect2: ld returned 1 exit status make: *** [main] Error 1 </code></pre>
c++
[6]
4,095,392
4,095,393
What's the point in storing objects in memory when you can store them in a databse?
<p>For my PHP based assignment, I believe I have to use objects (Including items like a collection class, collection iterator and so on), as well as a MySQL database. </p> <p>My question is, why would I need to create items as objects, store them in a database then create them as objects again when pulled out of the database when I can just put and get the items straight into and out of the database and use them for what I need straight away? </p> <p>Or perhaps better phrased, what would be the benefit, if there is one, of storing objects in PHP memory (Wherever PHP stores things), as well as storing them in a database as opposed to just storing them in a database?</p>
php
[2]
5,073,344
5,073,345
Why can't you assign an int to an Integer in a loop without curly braces?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/1974641/why-this-is-not-compiling-in-java">Why this is not compiling in Java?</a> </p> </blockquote> <p>In java, curly braces are optional for one line for loops, but I've found a case where it isn't allowed. For instance, this code:</p> <pre><code>for(int i = 0; i &lt; 10; i++) Integer a = i; </code></pre> <p>won't compile, but if you add curly braces, like so:</p> <pre><code>for(int i = 0; i &lt; 10; i++){ Integer a = i; } </code></pre> <p>it will. Why won't this code compile?</p>
java
[1]
3,210,596
3,210,597
What is best way to measure the time cycles for a C# function?
<p>Really, I'm looking for a good function that measure the time cycles accurately for a given C# function under Windows operating system. I tried these functions, but they both do not get accurate measure:</p> <pre><code>DateTime StartTime = DateTime.Now; TimeSpan ts = DateTime.Now.Subtract(StartTime); Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); //code to be measured stopWatch.Stop(); TimeSpan ts = stopWatch.Elapsed; </code></pre> <p>Really, each time I call them, they give me different time for the same function</p> <p>Please, if anyone know better way to measure time consuming accurately, please help me and thanks alot alot</p>
c#
[0]
2,342,138
2,342,139
how to disable a button for a specific time in php
<p>I have an edit button for users to edit their posted jobs. I want that button to disable or disappear a week after published day.how can I do this in php. thanks advance...</p>
php
[2]
2,043,981
2,043,982
Can I chain "or" statements like this?
<p>Given these variables:</p> <pre><code>$bar = false; $baz = false; $boo = "hi there"; $jelek = false; </code></pre> <p>When I chain <code>or</code> together like this:</p> <pre><code>$foo = $bar or $foo = $baz or $foo = $boo or $foo = $jelek; echo $foo; </code></pre> <p>It returns <code>hi there</code>! So, is this correct usage of <code>or</code>? Because if so, it's pretty sexy.</p>
php
[2]
1,469,702
1,469,703
definitive way to get user ip address php
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/6717926/function-to-get-user-ip-address">Function to get user ip address</a> </p> </blockquote> <pre><code>&lt;?PHP $ipaddress = $_SERVER["REMOTE_ADDR"]; Echo "Your IP is $ipaddress!"; ?&gt; </code></pre> <p>I was told this way of getting ip address has issues such as being able to fool. Is there a better way to gather ip address? looking for tutorials of better way to get ip address?</p>
php
[2]
5,860,660
5,860,661
iPhone dev: adding an overlapping label to the image
<p>I'm trying to figure out a best way to implement the picture-editing capability shown in the native address book app on iPhone.</p> <p>On the built-in address book, this is how the picture looks like before editing:</p> <p><img src="http://qkpic.com/2f7d4" alt="qkpic.com/2f7d4"></p> <p>And after clicking edit, notice how "Edit" overlay is added and the image becomes clickable:</p> <p><img src="http://qkpic.com/fb2f4" alt="qkpic.com/fb2f4"></p> <p>What would be the best way to implement something like this? Should I make the image a button from the beginning and have tapping disabled at first? If so, what steps are required to add an overlay/label to the image (in above example, gray border + the text "Edit" is added)</p>
iphone
[8]
2,360,254
2,360,255
Question Concerning a CodingBat Beginner Problem
<p>So I've been practicing my Java programming skills on the CodingBat website, when I came across <a href="http://codingbat.com/prob/p146974" rel="nofollow" title="this">this</a> problem. In it, you have to make a simple method that takes in an array of integers of dynamic length, check to see if the elements in the array are in increasing order (1, 2, 3, 15678, etc), and return "true" if true, or "false" if there is an integer out of order.</p> <p>Firstly, I initialize a boolean variable named "result". Then, I iterate through the array of integers passed by the method. If the current index value is less than the next index value, I set "result" to "true", and repeat the loop. Else, I'll set "result" to "false", break out of the loop and set "result" to "false". After the FOR loop, I return "result".</p> <p>However, I've been receiving an error message that "result" has not been initialized properly. I can kinda understand the confusing with the JVM, however I thought that setting the value for "result" inside of the IF/ELSE statements would solve that.</p> <p>Here is a copy of the code that I have done so far:</p> <p>EDIT: For posterity, I have edited out the wrong code for the correct code that works. Feel free to check it out and learn from it as I have. It appears that I forgot (among other things) to check the actual ELEMENT inside of the FOR loop, not necessarily the reference itself. Thanks a ton, everyone!</p> <pre><code>public boolean scoresIncreasing(int[] scores) { for (int i = 0; i &lt; scores.length - 1; i++) { if (scores[i] &gt; scores[i + 1]) { return false; } } return true; } </code></pre>
java
[1]
5,257,585
5,257,586
Get canvas height without drawing
<p>I wish to find out what dimensions my canvas is going to be long before I ever need to create one or draw on it.</p> <p>The only canvas code I know (or have a flimsy knowledge of) is this:</p> <pre><code> final SurfaceHolder holder = getHolder(); try { Canvas canvas = holder.lockCanvas(); if(canvas != null) { onDraw(canvas); holder.unlockCanvasAndPost(canvas); } } catch (Exception e) { e.printStackTrace(); } </code></pre> <p>But this looks like it is doing far too much for simply getting the height. Is there a function like WhatHeightWillMyCanvasBeWhenIMakeOne()? </p> <p><strong>EDIT:</strong> ...and if there isn't such a function, then what is a minimal piece of code for temporarily getting a canvas for long enough to ask its height and then get rid of it (if needed).</p>
android
[4]
1,493,783
1,493,784
How to create pull down effect
<p>Similar to this page. I could not identify the JS.</p> <p><a href="http://community.saucony.com/kinvara3/" rel="nofollow">http://community.saucony.com/kinvara3/</a></p> <p>Joey</p>
javascript
[3]
512,559
512,560
PHP to text function
<p>I am trying to create a function that would parse php code and return the result in pure text, as if it was being read in a browser. Like this one:</p> <pre><code>public function PHPToText($data, $php_text) { //TODO code return $text; } </code></pre> <p>I would call the function like this, with the params that you see below:</p> <pre><code>$data = array('email' =&gt; 'test@so.com'); $string = "&lt;?= " . '$data' . "['email']" . "?&gt;"; $text = $this-&gt;PHPToText($data, $string); </code></pre> <p>Now <code>echo $text</code> should give: <em>test@so.com</em></p> <p>Any ideas or a function that can achieve this nicely?</p> <p>Thanks!</p>
php
[2]
1,065,857
1,065,858
C# quick question regarding "this" keyword?
<p>Is this piece of code correct:</p> <pre><code>using (MyForm form = new MyForm { TopMost = TopMost}) { } </code></pre> <p>I want to make the new Form TopMost, if the parent Form is TopMost, or should I write like this, I mean the new Form TopMost property is not self assigned to itself.</p> <pre><code>using (MyForm form = new MyForm { TopMost = this.TopMost}) { } </code></pre>
c#
[0]
2,484,088
2,484,089
Confused: Pointers to Dynamic Arrays Syntax
<pre><code>int* p_bob = new int; *p_bob = 78; </code></pre> <p>The above code makes sense to me. I use the de-reference operation to allocation new memory and assign a value of 78.</p> <pre><code>int* p_dynint = new int[10]; *p_dynint[2] = 12; </code></pre> <p>This however doesn't make sense. If I try to use the de-reference operator on p_dynint[] I get an error. Why would an array be any different?</p>
c++
[6]
3,119,680
3,119,681
Python: tree structure and numerical codes?
<p>I'm using Python and I have some data that I want to put into a tree format and assign codes to. Here's some example data:</p> <pre><code>Africa North Africa Algeria Africa North Africa Morocco Africa West Africa Ghana Africa West Africa Sierra Leone </code></pre> <p>What would be an appropriate tree structure for this data?</p> <p>Also, is there a way that I can then retrieve numerical codes from this tree structure, so that I could query the data and get codes like the following example?</p> <pre><code>def get_code(place_name): # Python magic query to my tree structure return code get_code("Africa") # returns 1 get_code("North Africa") # returns 1.1 get_code("Morocco") # returns 1.1.2 </code></pre> <p>Thank you for your help - I still have much to learn about Python :)</p>
python
[7]
4,177,879
4,177,880
android how to kill a process or an app and detect some app restart again
<p>Recently,When I use some security applications,I find those application can kill others applications,but when I read api,the android just support some api to kill application itself,it doesn't support any other api directly to kill any process or application in phone.So how those security applications can kill other applications?Do those guys use some functions like linux "kill" system call?And I also find those security applications can clean RAM,Do they clean memory by killing app?The last question is some application can start itself when phone started,those some security applications can avoid this situation happening?But as I known,those applications register bootcompletion broadcastreceiver,so how security applications make those receiver disable?I hope someone who has experience on those areas can help me solve these questions,thanks a lot:)</p>
android
[4]
5,274,236
5,274,237
Empty set representation
<p>Could someone explain the following?</p> <pre><code>&gt;&gt;&gt; a = {1} &gt;&gt;&gt; b = {2} &gt;&gt;&gt; a &amp; b == set() True &gt;&gt;&gt; a &amp; b == {} False </code></pre> <p>Why is this choice made?</p>
python
[7]
1,835,264
1,835,265
GPS location provider availabilty issue
<p>my gps location provider takes at least one minute to be available. I took best provider, and it is "gps". What will be the reason for that? Anybody has any idea? My code is given below..</p> <pre><code>locationListener = new LocationListen(); Criteria criteria = new Criteria(); criteria.setAccuracy(Criteria.ACCURACY_FINE); locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); String provider = locationManager.getBestProvider(criteria, true); if(provider == null){ provider = LocationManager.GPS_PROVIDER; } if(!locationManager.isProviderEnabled(provider)){ locationManager.setTestProviderEnabled(provider, true); } boolean enabled = locationManager.isProviderEnabled(provider); if(enabled){ System.out.println("provider enabled"); // setAlert("provider enabled", "", false); }else{ System.out.println("provider disabled"); // setAlert("provider disabled", "", false); } locationManager.removeUpdates(locationListener); locationManager.requestLocationUpdates(provider, (long)1000, (float)0, locationListener); </code></pre> <p>onStatusChanged() method is called only after atleast a minute and changed status is the provider availability (available) after this onLoctionChanged() method is called. What will be the reason for delayed availability of gps location provider?</p>
android
[4]
590,375
590,376
I would like to know different style attributes of checkbox in xml in android program. here style attribute is **starStyle**
<pre><code>&lt;CheckBox android:id="@+id/star" style="?android:attr/starStyle android:layout_width="wrap_content" android:layout_height="wrap_content" /&gt; </code></pre> <p>I would like to know different style attributes of checkbox in xml in android program. here style attribute is <strong>starStyle</strong>.</p>
android
[4]
4,619,362
4,619,363
Find a control underneath parent in jQuery -- is this the cleanest way?
<p>If I wanted to find an element on the page, I would use $('#Foo');</p> <p>Now, I have a scenario where my 'this' context is a jQuery element. I would like to find an element underneath 'this.'</p> <p>I am using:</p> <pre><code>$(this).find('#Foo'); </code></pre> <p>I just wanted to make sure there wasn't a cleaner way of expressing this. If I wasn't in my this context, I might use something like $('#this #Foo'). It seems surprising that my jQuery selector query gets longer when I have an explicit reference to the 'this' jQuery element.</p>
jquery
[5]
5,745,330
5,745,331
Changing a String decimal (2.9) to Int or Long issues
<p>Okay, I'm fairly new to java but I'm learning quickly(hopefully). So anyway here is my problem:</p> <p>I have a string(For example we will use 2.9), I need to change this to either int or long or something similar that I can use to compare to another number.</p> <p>As far as I know int doesn't support decimals, I'm not sure if long does either? If not I need to know what does support decimals.</p> <p>This is the error: <code>java.lang.NumberFormatException: For input string: "2.9"</code> with both Interger.parseInt and Long.parseLong</p> <p>So any help would be appreciated!</p>
java
[1]
4,920,898
4,920,899
UIpickerview size is not reduced in iphone os 4.0
<p>i am i need to reduce size of UIPickerview.</p> <p>for that i use this code </p> <pre><code>picker = [[UIPickerView alloc] init]; picker.frame = CGRectMake(0, 0, 100, 100); </code></pre> <p>it is not reduce in os 4.0 and i test it in os 3.0 then it is reduced.</p> <p>what the wrong,how can i reduce size of UIPickerview in iphone os 4.0.</p> <p>can any one please help me.</p> <p>Thank u in advance. </p>
iphone
[8]
2,123,860
2,123,861
Activity handles specific file types - how to read the data?
<p>I need my activity to handle files of specific types downloaded from internet. Consider that browser successfully calls my activity. My activity gets Intent object. The question is how to read the downloaded file?</p> <p>Intent.getData() returns Uri to my file as I understand. Should I use HttpClient to get the file contents as described here?</p> <p><a href="http://stackoverflow.com/questions/3933807/how-to-read-files-clicked-in-the-android-web-browser">How to read files clicked in the Android web browser?</a></p> <p>But then doesnt it reload the file again over the network, while the browser seem to already has loaded the file?</p>
android
[4]
1,975,162
1,975,163
What are the available methods in C++ std library, where can I see/read them?
<p>Where can I see all the available methods in std library ? Since, I can include vector,algorithm in my program, can I see header/source files for this library to see how it is implemented ?</p> <p>eg. I know we can use push_back() method in vector, but where can I see all the methods for vector, and similarly for others library ? </p> <p>Is there any documentation for it ?</p> <p>I am using ubuntu, if this helps.</p>
c++
[6]