Unnamed: 0
int64
65
6.03M
Id
int64
66
6.03M
Title
stringlengths
10
191
input
stringlengths
23
4.18k
output
stringclasses
10 values
Tag_Number
stringclasses
10 values
1,732,710
1,732,711
Parsing response from Github
<p>How do I make string like <code>"payload={'key':'value'...}"</code> to become a variable <code>payload</code> with value assigned to it <code>"{'key':'value'...}"</code>? Thanks.</p>
python
[7]
5,815,724
5,815,725
How can i draw a compass like iphone 3gs in ios4?
<p>I'm trying to make a view like compass in iphone 3gs or iphone4. Do you know somebody how can I start?, I can't find too much information about this issue...I only want to draw an arrow always following the north. I'm using ios 4.0</p> <p>Thanks in advance</p>
iphone
[8]
5,735,949
5,735,950
I'm new in programming with C#
<p>How can I start with C#</p>
c#
[0]
2,636,547
2,636,548
C#: How to detect arguments typed into console application?
<p>How would I go upon detecting input for a console application in C#?</p> <p>Let's say for example I want the console application to start up by writing: Welcome To Food Hut (cursor to type stuff here after the first line)</p> <p>I would want the console application to detect two commands:</p> <p>1: /help - which will display some help gibberish.</p> <p>2: /food pizza -t pepperoni -d pepsi - which will display "So you would like a Pizza with Pepperoni and Pepsi to drink?"</p> <p>How would I go upon detecting first what /command was typed and also reading the arguments like -t pepperoni (topping) and -d pepsi (to drink) if /food pizza was typed?</p> <p>My main problem is figuring out how to detect the first word ever typed, figuring out that if it was /help then call some method that would post some help text into the console or if the command is /food then to read what is after the /food command, -t, and -p.</p> <pre><code> static void Main(string[] args) { Console.WriteLine("Welcome To Food Hut"); Console.ReadLine(); // if readline equals to /help then display some help text. // if /food command is typed, read first argument after /food Pizza, -t TheTopping // and -p ForWhatToDrink // and then display, 'So you would like a Pizza with Pepperoni and Pepsi to drink?' } </code></pre>
c#
[0]
1,664,121
1,664,122
Add row in list view in android
<p>I have a list view and i want to add 4 rows in the list view and each row contains progress bar and start button. For this purpose i have created another layout for row which contains progress bar and button. Now in my main activity i am writing the code but listview is not displaying.</p> <pre><code>ArrayAdapter adapter = new Arrayadaper(this, R.layout.row); ListView listView = (ListView) findViewById(R.id.listView1); listView.setAdapter(adapter); </code></pre>
android
[4]
4,667,621
4,667,622
finding the td with 0 value
<p>i have a table like this in my html page</p> <pre><code>&lt;table id="mytable"&gt; &lt;tr id="classified"&gt; &lt;td&gt;1&lt;/td&gt; &lt;/tr&gt; &lt;tr id="unclassified"&gt; &lt;td&gt;0&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p>so, on the document.ready i want to check which column has 0 value, if value is o then hide that row,</p> <p>i have written this code but doesnt seem to work</p> <pre><code>$(document).ready(function IsValidTableContent() { $('#mytable tr td').each(function () { if ($(this).val() == 0) { $(this).hide(); } else { $(this).show(); } }); }); </code></pre>
jquery
[5]
5,833,529
5,833,530
What are the uses of Method Handles in Java7?
<p>I see there is a new thing added up in Java7 named method handlers. For what scenario they are useful for?</p>
java
[1]
5,028,755
5,028,756
How can I show file in sdcard to user?
<p>I want to show user my apk file using intents, here is the code:</p> <pre><code> SDCardRoot = Environment.getExternalStorageDirectory(); File file = new File(SDCardRoot,fileName); if (file.exists()) { Uri path = Uri.fromFile(file); Intent intent = new Intent(Intent.ACTION_VIEW,path); startActivity(intent); </code></pre> <p>but it is giving me ActivityNotFoundException,I want to start the apk file so that user can install it.</p>
android
[4]
2,626,489
2,626,490
Android make call activity to check prepaid phone balance
<p>I would like to make an activity where i can call a certain numer to check my prepaid phone balance. In my provider its for example *555# then i will get a response like for example "Your remaining phone credit is 5 USD". I would like to use this data (5 USD) to save in the database.</p> <p>I am just a beginner, does someone know how to proceed?</p>
android
[4]
3,416,225
3,416,226
setBackgroundDrawable on multiple items not working properly
<p>I have a gallery which has 7 + linear layouts in each view, and I set the background drawable for 7 of these layouts dynamically, depending on data I pull from out db, the position of the gallery, etc. </p> <p>I have a for loop that launches 7 threads to fetch data and fetch the information needed for the drawables to be generated, all of which returns via a common handler, which in turn fetches each of the linear layouts and runs setBackgroundDrawable() on each of them.</p> <p>The problem I'm running into is that I can see my constructors for the drawable being run 7 times, but draw() is only called on 1 or 2 of them. If I scroll right or left, the same thing happens with the new view. However, if I scroll back to the already drawn screen, all 7 of the linear layouts have their backgrounds drawn properly.</p> <p>I've tried calling invalidate() and requestLayout() on the linear layouts, their parents, the gallery, but to no avail.</p> <p>I would post my code but there is a whole mass of it, and I'm crossing my fingers that my explanation provides enough background. I appreciate any help</p>
android
[4]
4,088,759
4,088,760
questions on 0xff
<p>I am working on a C++ code. Not very sure what the code below is trying to do. Would like someone's help on it.</p> <pre><code>int pval = t_gamma[depth[i]]; int lb = pval &amp; 0xff; switch (pval&gt;&gt;8) { case 0: depth_mid[3*i+0] = 255; depth_mid[3*i+1] = 255-lb; depth_mid[3*i+2] = 255-lb; break; case 1: depth_mid[3*i+0] = 255; depth_mid[3*i+1] = lb; depth_mid[3*i+2] = 0; break; case 2: depth_mid[3*i+0] = 255-lb; depth_mid[3*i+1] = 255; depth_mid[3*i+2] = 0; break; case 3: depth_mid[3*i+0] = 0; depth_mid[3*i+1] = 255; depth_mid[3*i+2] = lb; break; case 4: depth_mid[3*i+0] = 0; depth_mid[3*i+1] = 255-lb; depth_mid[3*i+2] = 255; break; case 5: depth_mid[3*i+0] = 0; depth_mid[3*i+1] = 0; depth_mid[3*i+2] = 255-lb; break; default: depth_mid[3*i+0] = 0; depth_mid[3*i+1] = 0; depth_mid[3*i+2] = 0; break; } </code></pre>
c++
[6]
4,560,241
4,560,242
jQuery function in .attr is called only once for all matching tags
<p>I'm teaching myself jQuery by writing the game of memory (where you turn tiles over two at a time, looking for matches).</p> <p>I have 16 img tags, each representing one of the tile faces. I have an array of 16 jpg file names. I want to set the src attribute of each img tag to a random selection from my array. To do so, I wrote a function that extracts a string from the array, removes the string from the array, and returns the string. I then use this function in the onReady handler this way:</p> <pre><code>$('.picture').attr( {src : extractArrayValue(cousinPictures)}); </code></pre> <p>This seems to work, except that it appears that the function extractArrayValue appears to be called only once across all 16 tags. All 16 img tags get the same image, but if I refresh the page they get a <em>different</em> same 16 image files.</p> <p>Am I correct about what's happening? And, if so, is there a straightforward way to force extractArrayValue to get called for each attribute that gets set?</p>
jquery
[5]
123,826
123,827
Javascript Combining Variables inside an Object
<p>Okay this seems really simple but I just can't get it to work. I need to combine variables in an obect. Something like this:</p> <pre><code>var i = { a: 1, b: " sheep", c: this.a + this.b } </code></pre> <p>So that later on I can do something like:</p> <pre><code>i.a = 3; console.log(i.c); </code></pre> <p>and get "3 sheep".</p> <p>Is this just silly? Or what is the closest thing to it?</p>
javascript
[3]
644,231
644,232
how to find colour depth and locale for iphone through code?
<p>how to find colour depth and locale for iphone through code?</p>
iphone
[8]
2,904,956
2,904,957
Take (n) characters from a string
<p>I have a string in java, of uncertain length, and I need to take the first 3 and last 3 characters and put them into new strings. Is there a simple way to do this?</p>
java
[1]
3,862,275
3,862,276
How to implement php interface
<p>When I visit </p> <p><code>http://localhost/oopphp5/Chapter2/interfacetest.php</code></p> <p>the following give an error and I would like to know why.</p> <p>error</p> <blockquote> <p>Fatal error: Class 'MySQLDriver' not found in /Users/teacher/Sites/oopphp5/Chapter2/interfacetest.php on line 6</p> </blockquote> <p>interface.dbdriver.php</p> <pre><code>interface DBDriver { public function connect(); public function execute($sql); } </code></pre> <p>class.mysqldriver.php</p> <pre><code>require_once("interface.dbdriver.php"); class MySQLDriver implements DBDriver { public function connect() { //connect to database echo "connected"; } public function execute($query) { //execute the query and output result echo "executed"; } } </code></pre> <p>interfacetest.php</p> <pre><code>require_once("class.mysqldriver.php"); $mysql = new MySQLDriver(); </code></pre> <p>Thanks in advance.</p> <p>Updated: changed to <code>require_once</code> but it still displays an error.</p>
php
[2]
602,386
602,387
django-tagging install fails
<p>i am getting this error while installing django-tagging,</p> <pre><code>krisdigitx-Satellite-Pro-L450D django-tagging # python setup.py install Traceback (most recent call last): File "setup.py", line 49, in &lt;module&gt; version_tuple = __import__('tagging').VERSION File "/home/site/krisdigitx/django-tagging/tagging/__init__.py", line 3, in &lt;module&gt; from tagging.managers import ModelTaggedItemManager, TagDescriptor File "/home/site/krisdigitx/django-tagging/tagging/managers.py", line 5, in &lt;module&gt; from django.contrib.contenttypes.models import ContentType File "/usr/lib/pymodules/python2.7/django/contrib/contenttypes/models.py", line 1, in &lt;module&gt; from django.db import models File "/usr/lib/pymodules/python2.7/django/db/__init__.py", line 14, in &lt;module&gt; if not settings.DATABASES: File "/usr/lib/pymodules/python2.7/django/utils/functional.py", line 276, in __getattr__ self._setup() File "/usr/lib/pymodules/python2.7/django/conf/__init__.py", line 40, in _setup self._wrapped = Settings(settings_module) File "/usr/lib/pymodules/python2.7/django/conf/__init__.py", line 75, in __init__ raise ImportError("Could not import settings '%s' (Is it on sys.path? Does it have syntax errors?): %s" % (self.SETTINGS_MODULE, e)) ImportError: Could not import settings 'krisdigitx.settings' (Is it on sys.path? Does it have syntax errors?): No module named krisdigitx.settings krisdigitx-Satellite-Pro-L450D django-tagging # </code></pre> <p>I have exported the environment variable on the commandline</p> <p>declare -x DJANGO_SETTINGS_MODULE="krisdigitx.settings"</p> <p>but i still get the error that the module cannot be found.</p>
python
[7]
5,007,026
5,007,027
How to compare 2 String array lists and get the elements which are same in both the array lists using java
<p>i have 2 array lists a and b containing string elements ex:- ( 1,2,3,4,5)</p> <p>a = {1,2.3.4.5} b= {3,4,5}</p> <p>I want to compare array lists a and b ( each element of a compared with each element of b ) and after comparison i want the elements which are same in both the array lists. How will i do this in java? </p>
java
[1]
1,780,936
1,780,937
How to close Activity with software keyboard after BACK press?
<p>I have an Activity, where I want the software keyboard to be alaways opened. How to close the Activity after BACK press, when keyboard is opened? Now I have to click BACK twice, first to close the keyboard and then to finish the Activity.</p>
android
[4]
4,966,112
4,966,113
Get all LI elements in array
<p>How can i make JS select every LI element inside a UL tag and put them into an array?</p> <pre><code> &lt;div id="navbar"&gt; &lt;ul&gt; &lt;li id="navbar-One"&gt;One&lt;/li &gt;&lt;li id="navbar-Two"&gt;Two&lt;/li &gt;&lt;li id="navbar-Three"&gt;Three&lt;/li &gt;&lt;li id="navbar-Four"&gt;Four&lt;/li &gt;&lt;li id="navbar-Five"&gt;Five&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; </code></pre> <p>Can i make it so JS gets each of them into an array eg navbar['0'] would return document.getElementById("navbar-One")?</p>
javascript
[3]
5,970,904
5,970,905
Difference between Panel control and Div
<p>I want to know what is difference between Panel control in asp.net and div with runat="server"? Since both render in div.And i want to know which one is best (conditions)?</p>
asp.net
[9]
904,608
904,609
string argument for array static method header help for java
<p>I have placed string argument in the method header called methodASet. Is it possible to use this string argument in the body and returns the words in the argument as a set? If so how do I do this? Thanks. </p> <pre><code>public class MyMates { private static Set&lt;String&gt; names; private static String[] name1 = null; private static String[] name2 = null; private static String[] name3 = null; public MyMates() { methodASet(); // (2) but I then get a error message "methodASet(java.lang.String) in myMates cannot applied to () names = new TreeSet&lt;String&gt;(); } public static void methodASet(String aTemp) { name1 = new String[]{"Amy", "Jose", "Jeremy", "Alice", "Patrick"}; name2 = new String[]{"Alan", "Amy", "Jeremy", "Helen", "Alexi"}; name3 = new String[]{"Adel", "Aaron", "Amy", "James", "Alice"}; return aTemp; // (1) is it like this? } </code></pre>
java
[1]
4,303,258
4,303,259
can any one help me creating a tab bar application?
<p>I am creating a tab bar application.I have selected the tab bar template.But the project is build and run one tab is always selected.I don't want this to happen.I want a home screen to come.I am new to iphone development.Can any one help me in doing this?</p>
iphone
[8]
517,047
517,048
Do nothing if RSS feed hasn't changed
<p>I want to run a Python script every so many minutes. The script starts by fetching the newest article from a rss-feed (using feedparser). What I want, is when the newest article is the same as the last time it ran, the script just ends. How do I accomplish this?</p>
python
[7]
4,778,606
4,778,607
Is there a pointer-to-member equivalent in Java?
<p>I have a class which holds some colors for a GUI, which the program can change to its liking. For a specific element of the GUI, I'd like to be able to specify a color which is a member of that class. In C++, I could use something like</p> <pre><code>int Pallete::*color = &amp;Pallete::highlight; Pallete pallete; // made in or passed to the constructor // ... void draw() { drawing.color(pallete.*color); // ... } </code></pre> <p>Is there an equivalent in java? I've thought about using <code>getField(String)</code> in the Class class, or keeping the colors in a Map with string keys, but neither of these seem like very good solutions, because they rely on strings, and the compiler can't enforce that they are actually members of Pallete. I could also put all of the color names in an enum, and have some getter function which returns the associated color, but that seems like more work for me.</p>
java
[1]
5,561,457
5,561,458
a secure way to access my pages
<p>I am having trouble trying to figure out how to solve an error in this code. I'm following a video tutorial.</p> <pre><code>//when your looking for path $core_path= dirname(__FILE__); if(empty($_GET['page']) &amp;&amp; in_array("{$_GET['page']}.page.inc.php",scandir("{$core_path}/pages"))==false){ echo'invalid page'; } </code></pre> <p>The error I get when i try testing this code on my wamp server is</p> <pre><code>Notice: Undefined index: page in C:\wamp\www\pm_system\core\init.inc.php on line 8 </code></pre>
php
[2]
322,195
322,196
Using Array class in parent and child windows (javascript question)
<p>I'm actually coding a case where a child popup window transfer data to parent window as:</p> <pre><code>var childArrayData = new Array(); childArrayData[0] = 'Data text1'; childArrayData[1] = 'Data text2'; childArrayData[2] = 'Data text3'; window.opener.parentVariable = childArrayData; </code></pre> <p>I got an error which was solved like:</p> <pre><code>var childArrayData = new window.opener.Array(); &lt;----- childArrayData[0] = 'Data text1'; childArrayData[1] = 'Data text2'; childArrayData[2] = 'Data text3'; window.opener.parentVariable = childArrayData; </code></pre> <p>Why is Array class different between two different windows? Does it relate to namespacing? May you refer to any article about the answer?</p> <p>Thanks in advance.</p> <p>Best,</p> <p>Esteve</p>
javascript
[3]
693,134
693,135
getimagesize not working
<p>I'm trying to get the image size but not managing to do it. What could be the problem?</p> <pre><code>$size = getimagesize("http://getfavicon.appspot.com/http://google.com?defaulticon=1pxgif"); echo $size[0]; </code></pre>
php
[2]
1,291,639
1,291,640
Is there a better way to write this navigation statement?
<p>I know this is a redundant way to write these rules so I'm wondering if anyone knows a better way to write it. Thanks!</p> <pre><code>$('.nav li a').eq(0).click(function() { $('.nav li a').eq(0).addClass("active"); $('.nav li a').eq(1).removeClass("active"); $('.nav li a').eq(2).removeClass("active"); $('.nav li a').eq(3).removeClass("active"); }); $('.nav li a').eq(1).click(function() { $('.nav li a').eq(0).removeClass("active"); $('.nav li a').eq(1).addClass("active"); $('.nav li a').eq(2).removeClass("active"); $('.nav li a').eq(3).removeClass("active"); }); $('.nav li a').eq(2).click(function() { $('.nav li a').eq(0).removeClass("active"); $('.nav li a').eq(1).removeClass("active"); $('.nav li a').eq(2).addClass("active"); $('.nav li a').eq(3).removeClass("active"); }); $('.nav li a').eq(3).click(function() { $('.nav li a').eq(0).removeClass("active"); $('.nav li a').eq(1).removeClass("active"); $('.nav li a').eq(2).removeClass("active"); $('.nav li a').eq(3).addClass("active"); }); </code></pre>
jquery
[5]
3,044,267
3,044,268
example of breaking the image into pieces in android
<p>i m making a puzzle and i want to break the image into 6 or 9 parts so if anyone have any idea or link then help me</p>
android
[4]
5,540,665
5,540,666
Create bit map font file from true type font
<p>I it possible to create a bit map font file from a true type font using java ?</p> <p>Thanks</p>
java
[1]
5,590,537
5,590,538
Deprecated: Assigning the return value of new by reference is deprecated in
<p>After installing Domain Trader 2.5.1 on my server getting this error</p> <pre>Deprecated: Assigning the return value of new by reference is deprecated in /home/user/public_html/pear/DB.php on line 310</pre> <p>I am using PHP5.3</p>
php
[2]
5,264,513
5,264,514
Where is c++ size_t defined in linux
<p>Now I'm talking about new type definition by a programmer using typedef keyword. As long as my pupils are used to the type size_t (for example by using funciton length ()), for which I had to ask them a little effort to just "believe" it is an integer type, I think it woud be great to show noew them where this type is defined.</p> <p>So, I've done a lot grep's in /usr/include in an ubuntu box, and what I see is that size_t is, in turn, a redefinition of size_type wich in turn is a redefinition of metadata_type, and that's the end in this directory. Not found the final "typedef unsigned int metadata_type;".</p> <p>In /usr/src I've found anohter previous type called yy_size_t,...</p> <p>But, in any case I've been unable the get to the end of the chain.</p> <p>Does anyone know where to find out the final definition to check out that it is an unsigned int (or the like)? May be I miss a development package in my box? In this case, why I'm able to compile programs using size_t type?</p>
c++
[6]
5,930,788
5,930,789
Creating method to draw a circle using the centre of the circle and radius
<p>The method I created worked to the point that it would create a circle in a pictureBox but it would only use the coordinates of a rectangle.</p> <p>I'm trying to create the following,</p> <ul> <li>Windows form with: <ul> <li>1 pictureBox</li> <li>1 textBox</li> <li>1 button</li> </ul></li> </ul> <p>textBox should be used to insert the radius for the circle. </p> <pre><code>(double input=Convert.ToDouble(textBox1.Text) { private void button1_Click(object sender, EventArgs e) { double input.... double radius= Math.PI*input*input; Graphics paper; paper = pictureBox1.CreateGraphics(); Pen pen = new Pen(Color.Black); getCircle(paper, pen, (variables for center), radius); } private void getCircle(Graphics drawingArea, Pen penToUse, int xPos, int yPos, double radius); { } } </code></pre> <p>My problem here being I have no idea how to create a circle using <code>Math.PI*radius*radius</code> with pre determined centre coordinates.</p> <p>I would like to see an answer with coded method and <code>button_click</code></p>
c#
[0]
956,609
956,610
How to create webpage preloading bar by jquery?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/8442363/how-to-create-a-jquery-loading-bar-like-the-ones-used-on-flash-sites">how to create a jQuery loading bar? (like the ones used on flash sites)</a> </p> </blockquote> <p>I want to make an animated preloading bar on page before the whole webpage being loaded, it should wait until the whole webpage is fully loaded , including images,media,scripts,css,ajax,div etc, how do I know are those elements actually loaded ? </p> <p>And what is the best way to create a loading bar like that? use a div to cover all the elements before they are loaded? But I see the div will blink.</p>
jquery
[5]
5,780,489
5,780,490
Getting a property value and passing it on to superclass
<p>I need to get a property value from a property file and then pass it on to a superclass constructor. But since <code>super(value);</code> should be called first, where should I load the file and get the property value?</p>
java
[1]
3,919,847
3,919,848
Javascript crop function without displaying image
<p>First of all, I'm very new to javascript. I'm trying to develop a javascript function which takes an image and returns a cropped version of that image. By looking around on google I've found that I probably need to use a canvas in some way to accomplish this task. But does that mean I have to display the image on my page? </p> <p>I've also looked at different javascript image processing libraries for a similar function, for example Pixastic's Crop, but I have no idea how to use it to solve my particular problem. So now I'm turning to you guys for help. Please guide me in the right direction!</p> <p>Thanks!</p>
javascript
[3]
1,195,329
1,195,330
adding of Coloumn values of a Layout inflater listview in Android
<p>I have a listview whose rows are added by using layout inflater concept. i want to add all values in one particular column and to display total in textbox. I tried more but the adding of all values in a column is not going on perfect. while scroling the listview...the values are changing.</p> <p>** Can it possible to add column values while using layout inflator concept</p>
android
[4]
1,942,017
1,942,018
What's wrong with this Python code?
<p>I'm very new so just learning, so go easy please!</p> <pre><code>start = int(input('How much did you start with?:' )) if start &lt; 0: print("That's impossible! Try again.") print(start = int(input('How much did you start with:' ))) if start &gt;= 0: print(inorout = raw_input('Cool! Now have you put money in or taken it out?: ')) if inorout == in: print(in = int(raw_input('Well done! How much did you put in?:'))) print(int(start + in)) </code></pre> <p>This always results in syntax error? I'm sure I'm doing something obvious wrong!</p> <p>Thanks!</p>
python
[7]
4,577,513
4,577,514
Where to find the Contact View in Android?
<p>I notice that some of the base applications in Android are using this little control (View in Android terms I guess) that shows the contact picture. When you click on the picture it shows all the ways of contacting the person (phone, sms, talk, facebook). I see this little View used in the contact app, sms app, twitter for android, facebook for android etc.</p> <p>Is there a library or a way of getting this working on my own application or do I need to write this from scratch?</p>
android
[4]
2,680,926
2,680,927
Why is this code giving me an "IndentationError: unexpected unindent"
<p>The code below is really annoying me I have looked on stackoverflow and google yet have not found anything and I am a pretty good pyton programmer and have not as of yet, well untill now, found an error that I could not deal with. I have tried everything but this peace of code is giving me the <strong>IndentationError: unexpected unindent</strong> which is weird because the normal error is "undexpected indent" which means as posted many times that its the spacing and how I spaced it so I went through the whole code and nada same error and I put in four spaces correctly and everything still ... nothing. help?</p> <pre><code>from bottle import Bottle, run, route, static_file, debug from mako.template import Template as temp from mako.lookup import TemplateLookup lookup = TemplateLookup(directories=[base+'/templates']) application = Bottle() if __name__ == '__main__': @route('/') else: @application.route('/') def index(): index_temp = lookup.get_template('index.html') return index_temp.render(site=site, corperate=corperate, copyright=copyright) </code></pre>
python
[7]
3,644,414
3,644,415
Android App --> Displaying Local News
<p>I'm developing an android app and am not sure if something like this exists or how to even approach it. I would appreciate any advice.</p> <p>In this app I would like to have a screen that displays only local news for a certain zip code. I would of course type in the zip code but after I do this once it would take it from there.</p> <p>What is the best way to do this?</p> <p>I've read a bit about RSS feeds. Is this the way to go? Is there a particular RSS feel that will let me type in a zip code...and if so, how do I display this content inside a page of my app?</p> <p>Maybe there is a website that specifically does this for android apps and I just need to set a url to this web page to consume the information?</p> <p>Sorry if I'm not very informed about this. This is my first app and I would really appreciate knowing how best to approach this problem.</p> <p>Thanks</p>
android
[4]
2,823,191
2,823,192
nsstring and const char* conversion
<p>i try to convert nsstring to const char*.</p> <p>1- i add a nsstring and an integer together<br> 2- then i convert this new nsstring to const char*<br> 3- i have an object and i attribute this new nsstring as my object's name.<br> 4- i use this object in another function</p> <blockquote> <p>NSString* firstName = [NSString stringWithFormat: @"Name%d", 1];<br> const char* secondName = [firstName cString];<br> myobject->setName(secondName);</p> </blockquote> <p>problem : A<br> 1- secondName is null when i use my object in my function.<br> 2- but if i replace firstName by : firstName = "Name1";<br> 3- it works</p> <p>problem B<br> 1- if i replace const char* secondName = [firstName cString];<br> by const char* secondName = [macString UTF8String];<br> 2- even if i have firstName = "Name1";<br> 3- this is not working !!</p> <p>any idea ??</p> <p>thank you </p> <p>:=)</p>
iphone
[8]
1,559,697
1,559,698
In Java, create a generic parsed string cache (multiple resulting types)
<p>I'm trying to create a generic parsed string cache to prevent rebuilding the same object over and over. Essentially, what I'm building is something like the following:</p> <pre><code>public class ParsedStringCache { // static Map&lt;Pair&lt;String, Parser&lt;T&gt;&gt;, T&gt; _cache // = new HashMap&lt;Pair&lt;String, Parser&lt;T&gt;&gt;, T&gt;(); public interface StringParser&lt;T&gt; { public T parseString(String stringToParse); } public static &lt;T&gt; T getParsedObject(String stringToParse, Parser&lt;T&gt; parser) { return parser.parseString(stringToParse); } } </code></pre> <p>This works fine until I try to actually cache the results, such as by using something similar to the commented out hashmap in the code above, which would essentially memoize the result of getParsedObject. Is there a reasonably simple way to do this that avoids casting?</p>
java
[1]
902,530
902,531
C++ --- Can a static member variable call non-static member functions
<p>I saw the following code:<br> <a href="http://sourcemaking.com/design_patterns/singleton/cpp/1" rel="nofollow">http://sourcemaking.com/design_patterns/singleton/cpp/1</a></p> <pre><code>class GlobalClass { private: int m_value; static GlobalClass *s_instance; GlobalClass(int v = 0) { m_value = v; } public: int get_value() { return m_value; } void set_value(int v) { m_value = v; } static GlobalClass *instance() { if (!s_instance) s_instance = new GlobalClass; return s_instance; } }; GlobalClass *GlobalClass::s_instance = 0; void foo(void) { GlobalClass::instance()-&gt;set_value(1); // static variable calls non-static functions cout &lt;&lt; "foo: global_ptr is " &lt;&lt; GlobalClass::instance()-&gt;get_value() &lt;&lt; '\n'; } </code></pre> <p>As I know (please correct me if I am wrong here),</p> <ol> <li><p>Static functions can only access(write/read) static member variables</p></li> <li><p>Non-Static functions can access(write/read) static member variables</p></li> </ol> <p>Based on above sample, it seems that a static variable can access non-static functions.<br> Is this correct?</p>
c++
[6]
616,649
616,650
How can I reshape and aggregate list of tuples in Python?
<p>I'm a newb to Python so apologies in advance if my question looks trivial.</p> <p>From a psycopg2 query i have a result in the form of a list of tuples looking like:</p> <pre><code>[(1, 0), (1, 0), (1, 1), (2, 1), (2, 2), (2, 2), (2, 2)] </code></pre> <p>Each tuple represents id of a location where event happened and hour of the day when event took place.</p> <p>I'd like to reshape and aggregate this list with subtotals for each hour in each location, to a form where it looks like:</p> <pre><code>[(1, 0, 2), (1, 1, 1), (1, 2, 0), (2, 0, 0), (2, 1, 1), (2, 3, 3)] </code></pre> <p>Where each touple will now tell me that, for example: in location 1, at hour 0 there were 2 events; in location 1, at hour 1 there was 1 event; and so on...</p> <p>If there were 0 events at certain hour, I still would like to see it, as for example 0 events at 0 hours in location 2: (2, 0, 0)</p> <p>How could I implement it in Python?</p> <p>EDIT: Thanks for help!</p>
python
[7]
5,395,307
5,395,308
Using a (to a class) unknown function
<p>I have a check if a form is already open. If it't not, it will open, if it is, it will activate the form + use a SwitchTab(int i) function. Here is some code:</p> <pre><code>public partial class Insert : Form { public Insert() { InitializeComponent(); } public Insert(int tab) : this() { SwitchTab(tab); } public void SwitchTab(int tab) { tabControl1.SelectedIndex = tab; } } private void OpenInsert(int tab) { // Loop through all forms foreach (Form f in Application.OpenForms) { // Check if form of Insert type is found if (f.GetType() == typeof(Insert)) { f.Activate(); // Unknown function f.SwitchTab(tab) return; } } // Not found, open form Insert insert = new Insert(tab); insert.Show(); } </code></pre> <p>The reason behind this is that the Insert form has multiple tabs and I want to switch tab if an other button in the menu is clicked. The problem is that where I want to call the SwitchTab() function, the compiler doesnt know that it's a Insert class, but it only passes when it is. So is there some way to forcefully let it know it's a instance of insert?</p>
c#
[0]
4,973,410
4,973,411
How to display data in MdiChild forms received from serialport
<p>Sir, I created a MDI Parent form and three Mdi Child forms. Each child form contains a button. on clicking the button a new form is displayed. Mean to say if I click all the 3 buttons in 3 child form then there will be 3 new forms displayed. Its Fine. </p> <p>My problems are :</p> <p>1- Each new form which is displayed on clicking the button is also shown in the taskbar. I want each new form(apart from mdi child form) to be the mdi child of the main mdi parent.</p> <p>2- These new forms diaplay the data received from the device connected via serialport. How many serialport objects I must create? If one, then where it must be created, on the Main mdi parent form or on the individual forms(3 new forms) ? If it is on the MDI parent form then how can i access that object in the 3 newly opened forms? If it is on the newly created forms then there would be 3 serialport objects accessing the same COM port which will result an Exception stating- "COM port is not accessible".</p> <p>PLease reply... I am recently passed out graduate and new in c#. SO please reply so that i can undrstand properly. Thanks....</p>
c#
[0]
4,213,262
4,213,263
problems importing scanner class
<p>I am trying to execute the following code but keep getting this error:</p> <blockquote> <p>Error: Main method not found in class ScannerDemo, please define the main method as: <code>public static void main(String[] args)</code></p> </blockquote> <pre><code>import java.util.Scanner; class ScannerDemo public class Main { public static void main (String [] args) { Scanner sc = new Scanner(System.in); String userName; System.out.println("Enter a number"); username = sc.nextLine(); System.out.println("your number is" + username + "enter your next number"); username2 = sc.nextline(); System.out.println("your total is" + username2 ); } } </code></pre> <p>I think I must be importing the Scanner class wrong, I have tried different methods but nothing has worked for me yet.</p>
java
[1]
2,361,732
2,361,733
Why does <body onload="fn();"> use a function call, but window.onload=fn; use a handler function?
<p>I've read about the technical differences such as which option waits for the appropriate elements to load, but for most cases I understand that they both serve a similar purpose. </p> <p>I'd like to know about the rationale behind needing to call the function (say, initialize();) when using but only using the function name if writing window.onload=myFunction. (MDN calls it a handler function). Here, I'm referring to the difference being the missing parentheses.</p> <p>Is there an advantage to either approach? A technical reason?</p>
javascript
[3]
4,410,040
4,410,041
Sort list of strings by integer suffix in python
<p>I have a list of strings:</p> <pre><code>[song_1, song_3, song_15, song_16, song_4, song_8] </code></pre> <p>I would like to sort them by the # at the end, unfortunately since the lower numbers aren't "08" and are "8", they are treated as larger than 15 in lexicographical order.</p> <p>I know I have to pass a key to the sort function, I saw this somewhere on this site to sort decimal numbers that are strings:</p> <pre><code>sorted(the_list, key=lambda a:map(int,a.split('.')) </code></pre> <p>But that was for "1.2, 2.5, 2.3" but I don't have that case. I thought of replacing '.' with '_' but from what I understand it converts both sides to ints, which will fail since the left side of the _ is a string.</p> <p>Any help would be appreciated</p> <p><strong>EDIT</strong>: I forgot to mention that all the prefixes are the same (song in this example)</p>
python
[7]
1,700,849
1,700,850
Is there an example of how to use a TouchDelegate in Android to increase the size of a view's click target?
<p>My understanding is that when you have a view that's too small to easily touch, you're supposed to use a TouchDelegate to increase the clickable region for that view.</p> <p>However, searching for usage examples on Google turn up multiple people asking the question, but few answers.</p> <p>Does anyone know the proper way to set up a touch delegate for a view to, say, increase its clickable region by 4 pixels in every direction?</p>
android
[4]
2,267,816
2,267,817
how to get #define symbol rather than value from predefine constants
<p>I have one C++ define statement as:</p> <pre><code>#define PING 10 </code></pre> <p>In my <code>main</code> function, I have something like:</p> <pre><code>int main() { int code; cout&lt;&lt;"enter command code"; cin&gt;&gt;code; // value entered 10 cout&lt;&lt;code; //here i want "PING" output instead of 10 return 0; } </code></pre> <p>How can I replace 10 with PING in my output?</p> <h3>Edit:</h3> <p>i will have multiple #define as</p> <pre><code>#define PING 10 #define STATUS 20 #define FETCH 74 #define ACK 12 #define TRAIL 9 #define EXIT 198 </code></pre> <p>now my bussiness logic will get only command code i.e 10 or 12 etc etc</p> <p>i want to retreive corresponding command name for that code..how is it possible??</p>
c++
[6]
811,498
811,499
what happens when we do go one page forward and one page back in browser does it hit the server and reload the page?
<p>In my code i am maintaining some session on page load and some button click. It works fine but in browser if do Go back one page or go forward one page it disturb all session.</p> <p>So what is the concept behind Go back one page, go forward one page in browser.</p> <p>When we go forward or go back, does page reload from the server.</p>
asp.net
[9]
4,455,303
4,455,304
getting null pointer exception on using savedInstanceState.getInt( "Phase", 1 );?
<p>I'm getting null pointer exception on this line inside OnCreate function:</p> <pre><code>int Phase = savedInstanceState.getInt( "Phase", 1 ); </code></pre> <p>According to what I read, this function should return the value associated with "Phase" or 1 if no mapping exits for the key "Phase". However for some reason I'm getting this exception, any ideas as to why this is happening?</p>
android
[4]
3,797,258
3,797,259
When should I change/assign __class__ attribute in Python?
<p>There are a few questions around SO that look into setting <code>__class__</code> attribute in Python. It is mostly seen as unexpected and dangerous. For example, this question contains answers that discuss the downsides:</p> <p><a href="http://stackoverflow.com/questions/13280680/how-dangerous-is-setting-self-class-to-something-else">How dangerous is setting self.__class__ to something else?</a></p> <p>However, are there any "good" uses of this language feature? Is there any criteria or principle as to when one should do this?</p>
python
[7]
5,236,681
5,236,682
Is there a way to get around having to reference Global variables inside a function in PHP?
<p>Is there a way to get around having to reference Global variables inside a function in PHP?</p> <p>I just hate having to use the 'global' keyword for every variable, and I've been told that using constants (as an alternative) in PHP affects performance badly.</p>
php
[2]
3,284,811
3,284,812
Getting coordinates from json parsing and displaying in mapview?
<p>through jsonparsing i parse all the string values again i need to display the latitude and longitude in the mapview.. where i need to store all the coordinates in a separate array anyone please help me .. thanks in advance</p>
android
[4]
4,896,501
4,896,502
Python Constructing the left-hand coefficient matrix:
<p>Constructing the left-hand coefficient matrix: Write a function which, when given a list of chemical species and a list of elements, will return a 2-D array representing the right-hand coefficient matrix A in either (3) or (7). Example: calling your func-tion with inputs of ['CO', 'H2O', 'CO2'] and ['C', 'H', 'O'] should return an output of array([[1, 0, 1], [0, 2, 0], [1, 1, 2]]). Hint: column vectors c1, c2, c3 and c4 can be assembled into a matrix with c [c1, c2, c3, c4] in SciPy.</p> <p>so I'm thinking import scipy but I dont know how to start this...</p>
python
[7]
1,245,406
1,245,407
Handling map of files in c++
<p>I need to write to a bunch of files simultaneously, so I decided to use <code>map &lt;string, ofstream&gt;</code>.</p> <pre><code>map&lt;string, ofstream&gt; MyFileMap; </code></pre> <p>I take a <code>vector&lt;string&gt; FileInd</code>, which consists of, say <code>"a" "b" "c"</code>, and try to open my files with:</p> <pre><code>for (vector&lt;string&gt;::iterator it = FileInd.begin(); iter != FileInd.end(); ++it){ ... MyFileMap[*it].open("/myhomefolder/"+(*it)+"."); } </code></pre> <p>I get the error</p> <pre><code>request for member 'open' in ..... , which is of non-class type 'std::ofstream*' </code></pre> <p>I've tried to switch to </p> <pre><code>map&lt;string, ofstream*&gt; MyFileMap; </code></pre> <p>But it didn't work either.</p> <p>Could anyone help?</p> <p>Thanks.</p> <p><strong>Clarification:</strong></p> <p>I've tried both </p> <p><code>map&lt;string, ofstream&gt; MyFileMap;</code> <code>map&lt;string, ofstream*&gt; MyFileMap;</code> </p> <p>with both</p> <p><code>.open</code> <code>-&gt;open</code></p> <p>neither of 4 variants work.</p> <p><strong>Solution (suggested in Rob's code below):</strong></p> <p>Basically, I forgot "new", the following works for me:</p> <pre><code>map&lt;string, ofstream*&gt; MyFileMap; MyFileMap[*it] = new ofstream("/myhomefolder/"+(*it)+"."); </code></pre>
c++
[6]
4,436,866
4,436,867
PHP date() formatting
<p>I'm trying to format my date like YYYY-MM-DD. </p> <p>I'm doing this:</p> <pre><code> $dateAdded = date(Y-m-d); </code></pre> <p>So for today, it should say 2011-05-07, but it keeps returning 0000-00-00. Any help?</p>
php
[2]
267,094
267,095
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]
2,722,168
2,722,169
Make all the words in a string with 3 characters or less completely uppercase
<p>I trying to accomplish the following:</p> <pre><code>$string = "i want to convert this string to the following"; </code></pre> <p>and convert it to something like this:</p> <pre><code>echo $string; // I Want TO Convert This String TO THE Following </code></pre> <p>Thus: Capitalize the First Letter of All Words in a string and if a word is 3 characters or less, make the whole word Capitalized in the string. How cant this be done with PHP?</p>
php
[2]
722,306
722,307
How do I get started using Java for web development?
<p>OK, here's the easiest question for the day for those of you who have ever done this. I'm learning Java and I heard that Java can be used to build websites. I am coming from a PHP background, so I would really appreciate using a strongly-typed well-designed language like Java for web development. However, either I can't get my search keywords right, or there's not a single guide out there that will explain what I actually need to do to build websites in Java.</p> <p>For PHP, I would need to install Apache and PHP, or a nice package like WAMP, and start putting php files in the web root. </p> <p>What is Java's equivalent?</p>
java
[1]
2,954,016
2,954,017
How do I get an animation to play at the same time as a TextToSpeech utterance in Android
<p>I have a set of buttons in my ChordActivity application in a LinearLayout. When a button is clicked, I want the TextToSpeech engine to speak the name of the button clicked ( e.g; Minor 7th ), which is working fine. I also want an animation of the button 'popping out then back' to occur, which I also have working. The problem is that no matter how I arrange the code, the speech happens first, then the animation happens afterward. I want them to happen at the same time. I know that TextToSpeech has its own message queue, so I assumed that if I used a runnable to do the animation, I could get the speech and the animation to happen simultaneously, but it doesn't. I then backed out the runnable and now have the following code. Does anyone have a solution for this? Much Appreciated.</p> <pre><code>private void speakChordMessage(View v) { image = (ImageView) v; image.startAnimation(animScale); chordTTS.playSilence(2000, TextToSpeech.QUEUE_FLUSH, null); chordTTS.speak(str1, TextToSpeech.QUEUE_FLUSH, null); while (chordTTS.isSpeaking()) { } } </code></pre> <p>animscale.xml code:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_decelerate_interpolator" &gt; &lt;scale android:duration="200" android:fromXScale="1.0" android:fromYScale="1.0" android:pivotX="100%" android:pivotY="0%" android:repeatCount="1" android:repeatMode="reverse" android:startOffset="0" android:toXScale="1.3" android:toYScale="1.25" /&gt; &lt;/set&gt; </code></pre>
android
[4]
1,255,103
1,255,104
javascript global variables visibility
<p>I'm using a global variable in javascript, declared in a script tag outside any function:</p> <pre><code>&lt;script type="text/javascript"&gt; var prov_status_dict={}; .... &lt;/script&gt; </code></pre> <p>Later on in a javascript method I'm using the variable normally.</p> <pre><code>temp=prov_status_dict[current_as_id]; </code></pre> <p>I'm having issues with it on opera and ie, while on firefox it works. This is what opera's error console reports:</p> <pre><code>JavaScript - http://localhost:8000/input/ Event thread: click Error: name: ReferenceError message: Statement on line 62: Undefined variable: prov_status_dict stacktrace: n/a; see opera:config#UserPrefs|Exceptions Have Stacktrace </code></pre> <p>I've noticed that the problem is with global variables in general. I tryed moving some into hidden fields, but the same error pops up on the next use of a global var.</p> <p>Help?</p>
javascript
[3]
926,583
926,584
Is possible to create pinch zoom in view pager in android ?
<p>I want to create a horizontal scroll view with pinch zoom.I have tried for View Pager but then zooming is not happening.</p>
android
[4]
4,150,054
4,150,055
detect UITableViewCell id on UIImageView
<p>I have a UITableView. I place an UIImageView on each row UITableViewCell. I used the codes below to detect the touch on the UIImageViews</p> <pre><code>-(void) touchBegan:(NSSet*) touches withEven:(UIEvent*)event { CGPoint pt=[[touches anyObject] locationInView:self]; } </code></pre> <p>It looks like I can only get the pt, Is it possbile to detect which row's UIImageView is touched?</p> <p>Thanks</p> <p>interdev</p>
iphone
[8]
5,591,646
5,591,647
PHP Syntax validator?
<p>Im just wondering if theres a recommended syntax validator out there anybody can recommend?</p> <p>Having major issues and cant figure it out...</p> <pre><code> &lt;?php session_start(); if (isset ($_SESSION['id'])) {header("location: home.php");} if (array_key_exists("login", $_GET)){$oauth_provider = $_GET['oauth_provider']; if ($oauth_provider == 'twitter') { header("Location: login-twitter.php"); } else if ($oauth_provider == 'facebook'){ header("Location: login-facebook.php"); } } ?&gt; &lt;a href="?login&amp;oauth_provider=twitter"&gt;Twitter_Login&lt;/a&gt; &lt;a href="?login&amp;oauth_provider=facebook"&gt;Facebook_Login&lt;/a&gt; </code></pre>
php
[2]
6,023,583
6,023,584
how to generate unique number for users that visit a site using javascript?
<p>I want to generate unique number for each of my site users. How can I achieve something like this using JavaScript?</p> <p>P.S: I also want this unique number have information about users for example something like IP or concatenation something with IP. Can I have user IP using JavaScript?how?</p>
javascript
[3]
2,588,419
2,588,420
jQuery selector for select option not working in ie?
<p><pre><code>jQuery('#by option:eq(2)').hide();</code></pre> this is not working in ie. Here by is the id of select element.</p>
jquery
[5]
258,409
258,410
iPhone - accessing unknown getter method in a class
<p>I have this class that has a delegate method. Its delegate has a navigationController.</p> <p>I am trying to send a message to this navigationController from inside that class. Something like:</p> <pre><code>[delegate.navigationController setNavigationBarHidden:NO]; </code></pre> <p>I am receiving the message: <strong>error: accessing unknown 'navigationController' getter method</strong></p> <p>when I am inside the delegate, I can access its navigationController using</p> <pre><code>self.navigationController </code></pre> <p>How do I set the getter on that class, so this will work?</p> <p>thanks.</p>
iphone
[8]
427,190
427,191
Change background-image with jQuery - doesn´t work
<pre><code>$('#areaView').css('background-image', 'url(/areaNr1.jpg)'); </code></pre> <p>I don´t know what to say, I have no idea why this code doesn´t work. The old background-image disappears, but the new one never appears.</p> <p>I have checked and areaNr1.jpg exists in the same folder as the code. Allthough the function isn´t in the same folder as #areaView, but that should not matter, right?</p> <p>Any ideas why this doesn´t work?</p> <p>Thanks for your help!</p>
jquery
[5]
4,548,474
4,548,475
NullPointerException error in AVL tree
<p>I am doing an assignment about AVL trees in Java. I am getting a <code>NullPointerException</code> error when trying to balance the tree by means of the rotation. Can you please help me in finding the error? Here is my code:</p> <pre><code>public class Node { private int value; private Node leftNode; private Node rightNode; public Node(int value) { this.value = value; } </code></pre>
java
[1]
4,396,246
4,396,247
expected constructor, destructor, or type conversion before '<<' token
<p>On Compiling follow programs using g++. </p> <pre><code>#include&lt;iostream&gt; using namespace std; cout&lt;&lt;"Before Main"&lt;&lt;endl; int main() { cout&lt;&lt;"Within Main"&lt;&lt;endl; } </code></pre> <p>Errors: expected constructor, destructor, or type conversion before '&lt;&lt;' token. So may i know how to fixe this. What's the reason for getting erros.</p>
c++
[6]
3,259,611
3,259,612
iframe onmouseout capture
<p>I currently have an iframe within my parent page and I was wondering whether it's possible to capture a onmouseout event to trap when the user clicks or moves outside the iframe border, i.e back onto parent page.</p> <p>Would really appreciate some help.</p> <p>Thanks. Tony.</p>
javascript
[3]
1,823,142
1,823,143
problem with UISegmentedControl
<pre><code>-(IBAction)changeSegmentDistance:(UISegmentedControl *)sender{ // refineDistance=sender; switch ([refineDistance selectedSegmentIndex]) { case 0: valueString=5; NSLog(@"value String %d",valueString); break; case 1: valueString=10; NSLog(@"value Stringaaaa %d",valueString); case 2: valueString=15; NSLog(@"value String %d",valueString); break; case 3: valueString=16; NSLog(@"value String %d",valueString); break; default: break; } } </code></pre> <p>When i running application and printing on Console </p> <p>using NSLog...</p> <p>when i select 0 its printing 5... when i selected 1 its printing 10 and 15 when i selected 2 its printing 15 when i selected 3 its printed 16..</p> <p>I dont know why its printing 10 and 15 when i selected 2nd.</p>
iphone
[8]
3,066,611
3,066,612
Draw a timetable in console out of 3D-Array
<p>I want to draw a timetable in console application:</p> <pre><code>--------------------------------------------------- | Mo | Tu | We | ... | --------------------------------------------------- 1| Math | | | | | Teacher | | | | | Room | | | | --------------------------------------------------- 2| ... </code></pre> <p>I guess it's an 3D-Array. Dimension 1 is x, dimension 2 is y and dimension 3 is an object called "lesson". The properties of the lesson-objects are topic, teacher, room and others (begin, end, ...)</p> <pre><code> ------------------------------------------------------------------------- | Mo | Tu | We | ... | ------------------------------------------------------------------------- | Math | | | | | Teacher | | | | | Room | | | | | Begin: 2012.1.1 | | | | ------------------------------------------------------------------------- </code></pre> <p>The appearance should automatically fit rows, width and so on.</p> <p>A really cool solution can be <a href="http://stackoverflow.com/a/856918/1208574">found here</a></p> <p>But the solution is only 2D. I did some investigation, but cannot fill in complete object.</p>
c#
[0]
5,391,701
5,391,702
How do I reduce the height of a TableView when it is constructed in IB?
<p>I wanted to add a view to the bottom of my screen. The controller is a UITableViewController, how do I shrink the tableView and add a extra view at the bottom of the tableview?</p> <p>I've tried setting the frame of self.tableView in different places (viewDidLoad, viewWillAppear etc) but nothing happens. The tableView is created by IB and not programtically.</p> <p>I've tried added a footer to my table view but that's not what I want, because the footer actually scrolls up, I want a static non moving View at the bottom of the screen.</p>
iphone
[8]
1,184,628
1,184,629
How to get the Jquery row ID on single click
<pre><code> var value; $("#Grid1").click(function(e) { var row = jQuery(e.target).parent(); value= row.attr("id"); }); var onrowclick = function() { ("#Grid1").click($("#showgrid").load('/Names/Friends/satish/' + value)); }; </code></pre> <p>i am trying to send the value on URL.. when I am giving like this I am not getting the output result... am I doing this correctly?</p> <p>is the problem that I am handling click event on same grid two times?</p>
jquery
[5]
1,858,821
1,858,822
error in python: list assignment index out of range
<p>I searched everywhere and even though there were a couple of questions and answers regarding this error I couldn't find a solution to fix my problem</p> <p>I'm reading in from a file that contains letters and numbers and I'm populating my matrix depending on the values in that file. ex: file description of letters and numbers ... table:</p> <pre><code> a b c d a 1 2 5 6 b 5 6 3 4 c 3 2 1 4 d 2 4 6 8 </code></pre> <p>Here's the code</p> <pre><code>matrix = [[0 for j in range(4)] for i in range(4)] i = 0 j = 0 for line in file: for a in line: if is_number(a): matrix[i][j] = int(a) j+= 1 if matrix.count(0) &lt; 2: #since matrix already populated with zeroes. it shouldn't have #many per program specifications, that's why I use this #conditional to increment i and reset j back to 0 i += 1 j = 0 file.close() </code></pre> <p>I don't understand why I keep getting that error. </p>
python
[7]
4,494,780
4,494,781
Python is converting double quotes to single quotes in new variable
<p>I'm trying to save a variable with double quotes in python, because I need to pass the double quoted JSON to a template and single quotes wont work with what I'm doing. So I set the variable in python to:</p> <pre><code>json = { "auth": { "key": "auth-code-here" }, "template_id": "id-here", "redirect_url": "url-here", } </code></pre> <p>But immediate in python, it's saved as </p> <pre><code>{'redirect_url': 'url-here', 'template_id': 'id-here', 'auth': {'key': 'auth-code-here'}} </code></pre> <p>Is there a way I can save it as double quoted? Or will I need to process this in a django template to replace the single quotes for double quotes?</p> <p>Thanks!</p>
python
[7]
1,720,694
1,720,695
Reading to hash table from file c#
<p>(In this windows form application) I'm trying to read data from a file into a hash table and populate text boxes with the data in the hash table but when I run the code I'm always thrown the exception "Item has already been added. Key in dictionary: '' Key being added: '' "</p> <p>Initial code:</p> <pre><code>string[] fileLines = File.ReadAllLines(@"C:path/ajand.txt"); foreach (string line in fileLines) { // to split the first 9 chars in the string and use them as key values string[] match = Regex.Split(line, line.Substring(0,9)); hT.Add(match[0], line); } </code></pre> <p>so i tried checking for key duplicates with the following code</p> <pre><code> string[] fileLines = File.ReadAllLines(@"C:path/ajand.txt"); foreach (string line in fileLines) { string[] match = Regex.Split(line, line.Substring(0,9)); if(!hT.ContainsKey(match[0])) // to check duplicates hT.Add(match[0], line); } </code></pre> <p>But when I run the program the corresponding text boxes are not populated with the data that "seems" to have been added to the hash table. Please any ideas what the problem is.</p>
c#
[0]
2,397,439
2,397,440
Python string representation of binary data
<p>I'm trying to understand the way Python displays strings representing binary data.</p> <p>Here's an example using <a href="http://docs.python.org/library/os.html#os.urandom" rel="nofollow">os.urandom</a></p> <pre><code>In [1]: random_bytes = os.urandom(4) In [2]: random_bytes Out[2]: '\xfd\xa9\xbe\x87' In [3]: random_bytes = os.urandom(4) In [4]: random_bytes Out[4]: '\r\x9eq\xce' </code></pre> <p>In the first example of <code>random_bytes</code>, after each \x there seem to be values in hexadecimal form: fd a9 be 87.</p> <p>In the second example, however, I don't understand why <code>'\r\x9eq\xce'</code> is displayed.</p> <p>Why does Python show me these random bytes in this particular representation? How should I interpret <code>'\r\x9eq\xce'</code>?</p>
python
[7]
2,121,309
2,121,310
Proper way to add functionality to handle() in a python TCP Server?
<p>I have code like this:</p> <pre><code>class SingleTCPHandler(SocketServer.BaseRequestHandler): """ One instance per connection. """ def handle(self): data = Net.recv_from_socket(self.request) GUI.run(str("RECV'd message: %s" % data)) class SimpleServer(SocketServer.ThreadingMixIn, SocketServer.TCPServer): def __init__(self, server_address, RequestHandlerClass): SocketServer.TCPServer.__init__(self, server_address, RequestHandlerClass) </code></pre> <p>But I don't want to have to use <code>GUI</code>, a global variable, to contain the function that I want to call when a message is received by my server. Instead I want to send the <code>SingleTCPHandler</code> class the <code>GUI</code> object so it can call the function locally instead of referencing a global variable.</p> <p>Thoughts? Little new to python...</p>
python
[7]
5,765,735
5,765,736
removeChild work only every other time
<p>I try put one element next second, and delete second element, but it does not work. Look at example: <a href="http://jsfiddle.net/CZCGG/" rel="nofollow">http://jsfiddle.net/CZCGG/</a></p>
javascript
[3]
1,398,261
1,398,262
Android camera input similar to xbox kinect
<p>This is probably not possible but are there any API's that allow camera input on Android similar to what is possible with the Xbox kinect. Simpler capabilities I'm sure.</p>
android
[4]
4,083,257
4,083,258
Simple Sentence Reverser in C++
<p>I'm trying to build a program to solve a problem in a text book I bought recently and it's just driving me crazy.</p> <p>I have to built a sentence reverser so I get the following:</p> <p>Input = "Do or do not, there is no try." Output = "try. no is there not, do or Do"</p> <p>Here's what I've got so far:</p> <pre><code>void ReverseString::reversalOperation(char str[]) { char* buffer; int stringReadPos, wordReadPos, writePos = 0; // Position of the last character is length -1 stringReadPos = strlen(str) - 1; buffer = new char[stringReadPos+1]; while (stringReadPos &gt;= 0) { if (str[stringReadPos] == ' ') { wordReadPos = stringReadPos + 1; buffer[writePos++] = str[stringReadPos--]; while (str[wordReadPos] != ' ') { buffer[writePos] = str[wordReadPos]; writePos++; wordReadPos++; } } else { stringReadPos--; } } cout &lt;&lt; str &lt;&lt; endl; cout &lt;&lt; buffer &lt;&lt; endl; } </code></pre> <p>I was sure I was on the right track but all I get for an output is the very first word ("try.") I've been staring at this code so long I can't make any headway. Initially I was checking in the inner while look for a '/0' character as well but it didn't seem to like that so I took it out.</p>
c++
[6]
1,086,011
1,086,012
Reverse engineering option in Visual studio 2008 arch edition
<p>We have visual studio 2008 architecture installed and a c# solution created. We need to generate UML diagram (showing the classes, the relationship between them etc). In the architecture edition we don't see any option that would generate such diagram. The option of class digram mearly generates the class diagram but do not show such relationship. Is anyone aware of this?</p> <p>Thanks in advance. </p>
c#
[0]
3,866,091
3,866,092
Document to String?
<p>I've been fiddling with this for over twenty minutes and my Google-foo is failing me.</p> <p>Let's say I have an XML Document created in Java (org.w3c.dom.Document):</p> <pre><code>DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); Document document = docBuilder.newDocument(); Element rootElement = document.createElement("RootElement"); Element childElement = document.createElement("ChildElement"); childElement.appendChild(document.createTextNode("Child Text")); rootElement.appendChild(childElement); document.appendChild(rootElement); String documentConvertedToString = "?" // &lt;---- How? </code></pre> <p>How do I convert the document object into a text string?</p>
java
[1]
4,557,807
4,557,808
authentication mode="Forms" login https to default http
<p>I'm trying to use Forms Authentication to redirect from my login page (https) to my default page (http). </p> <pre><code>&lt;forms name="mysite.com" loginUrl="https://www.mysite.com/Login.aspx" protection="All" defaultUrl="http://www.mysite.com/Default.aspx" requireSSL="false" timeout="30" slidingExpiration="true" cookieless="UseCookies"&gt;&lt;/forms&gt; </code></pre> <p>After a successfull login using:</p> <pre><code>Response.Redirect(FormsAuthentication.DefaultUrl, True) </code></pre> <p>The default page is still returned over https.</p> <p>Am I doing something wrong? Or is there a better way to achieve this? </p>
asp.net
[9]
864,753
864,754
the best approach to giving an error message when validating
<p>I am a new programmer and am attempting to do some validation for a basic registration form. I have built a basic registration form that sends the user back to the same page when submitted. I have also created a user class and have created some basic validation functions. However, the functions have the error messages built into them. I obviously put the functions on the top of the registration form so when there is an error the errors are posted on the registration form. However, I have no control on how the error messages look and would like to know if there is a lot better way to somehow echo the error messages from outside the class so I can use some type of css or something else for better control of how they look. I hope that makes sense. Also when there is an error the user is sent back to an empty registration form. I was trying to figure out how to keep the valid information in the text boxes and just make them redo the invalid information. Here is a basic example of a validation I have done. I know its basic but I am very new to programming</p> <pre><code>function validate_password($password) { $valid = TRUE; if ($password == '') { echo "&lt;p&gt; Please enter a value for the password &lt;/p&gt;"; $valid = FALSE; } elseif($_POST['pwd'] !== $_POST['pwd2']) { echo "The passwords do not match please try again"; $valid = FALSE; } return $valid; } </code></pre>
php
[2]
1,348,515
1,348,516
entering date into database through three dropdownlists for day, month, and year
<p>I am using three dropdownlists for day, month, and year simultaneously and concatenating their results to generate a string in format 12/12/1999. But as the database table's field type is datetime it does not support this format.</p>
asp.net
[9]
2,352,588
2,352,589
Multiple assignment using map function
<p>Is it possible to apply map functions to multiple values at once? </p> <p>Something like this</p> <pre><code>from collections import defaultdict d['a'] = [1,2,3,4] d['b'] = [4,5,6,7] d['a'], d['b'] = map(lambda x,y: (x,y) if x*y % 3 == 0 else (0,0), d['a'], d['b']) --------------------------------------------------------------------------- ValueError Traceback (most recent call last) &lt;ipython-input-129-5191c9205e6f&gt; in &lt;module&gt;() ----&gt; 1 d['a'], d['b'] = map(lambda x,y: (x,y) if x*y % 3 == 0 else (0,0), d['a'], d['b']) ValueError: too many values to unpack </code></pre> <p>It is of course possible to do this individually. </p> <pre><code> l = map(lambda x,y: x if x*y % 3 == 0 else 0, d['a'],d['b']) m = map(lambda x,y: x if x*y % 3 == 0 else 0, d['b'],d['a']) d['a'] = l d['b'] = m d defaultdict(&lt;type 'list'&gt;, {'a': [0, 0, 3, 0], 'b': [0, 0, 6, 0]}) </code></pre>
python
[7]
1,936,802
1,936,803
Which is better if(a) or if(a!=NULL)
<p>if a is a pointer, is there a difference between testing if(a) and if(a != NULL) ? Which one is better?</p>
c++
[6]
3,820,204
3,820,205
Run Task scheduler at every 2 minute
<p>I want to create Task Scheduler that trigger at every 2 minute. I am using following namesapce</p> <p>using Microsoft.Win32.TaskScheduler</p> <p>I have written following code </p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.Win32.TaskScheduler; namespace SchedulerTest1 { class Program { static void Main(string[] args) { // Get the service on the local machine using (TaskService ts = new TaskService()) { // Create a new task definition and assign properties TaskDefinition td = ts.NewTask(); td.RegistrationInfo.Description = "Does something"; // Create a trigger that will fire the task at this time every other day td.Triggers.Add(new DailyTrigger()); // Create an action that will launch Notepad whenever the trigger fires td.Actions.Add(new ExecAction("notepad.exe", "D:\\test.log", null)); // Register the task in the root folder ts.RootFolder.RegisterTaskDefinition(@"Test", td); // Remove the task we just created ts.RootFolder.DeleteTask("Test"); } } } } </code></pre> <p>I want to run task at every 2 minute. What need to required to update in my code? Help me</p>
c#
[0]
3,288,207
3,288,208
Querying the status of a bit flag?
<p>I am trying to parse some files that have a bitwise flag column. There are 11 bits in this flag and I need to find out, for each row in the files, what is the value of the 5th bit (1-based).</p>
c++
[6]
1,546,023
1,546,024
How to get Date (yyyy/mm/dd) from ticks without using an instance/helper of/from Datetime C#
<p>I'm trying to extract date from ticks.</p> <p>Am I right that, a millisecond is 10000 ticks. and a day is 864000000000 ticks and a month is 26784000000000 and a year is 316224000000000.</p> <p>but when I use these in computations, I get wrong date :(.</p> <p>It could have been easy using Datetime parse but, for some reasons they say that I shouldn't rely on it as it is rather slower.</p> <p>Would appreciate your help. Thank you.</p> <p>UPDATE:</p> <pre><code>//assume this for now DateTime time = DateTime.Now; char[] ashigakaricom= new char[] { 'yyyy','-','mm','-','dd','-','H','H',':','M','M',':','S','S',':','m','m','m' }; long ticks = time.Ticks; int n1 = (int)(ticks &gt;&gt; 32); int n2 = (int)ticks; if (n2 &lt; 0) n1++; ticks = (((Math.BigMul(429497, n2) - (int)(Math.BigMul(1161359156, n2) &gt;&gt; 32) - Math.BigMul(1161359156, n1)) &gt;&gt; 32)) + Math.BigMul(n1, 429497); n1 = (int)(ticks &gt;&gt; 32); n2 = (int)ticks; if (n2 &lt; 0) n1++; int q = n1 * 50 + ((50 * (n2 &gt;&gt; 16)) &gt;&gt; 16) - (int)(System.Math.BigMul(1244382467, n1) &gt;&gt; 32) - 1; int r = (int)(ticks - System.Math.BigMul(q, 86400000)); if (r &gt; 86400000) r -= 86400000; //so on </code></pre>
c#
[0]
698,982
698,983
how to set element center in the div
<p>suppose i have text, images etc in div. so how can i make the element center horizontally and vertically in the div with the help javascript &amp; css. please guide with sample code. </p> <p>thanks</p>
javascript
[3]
3,995,296
3,995,297
How to place exceptions in files?
<p>I have different kinds of exceptions in a library which i am developing.</p> <p>What do you recommend placing them in a single file or a file with each kind of exception?</p> <p>Pls answer remembering that this is a library i am developing.</p>
c#
[0]