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 |
|---|---|---|---|---|---|
5,894,280 | 5,894,281 | Dynamically select a comparison operator (>=, <=, etc) in a conditional? | <pre><code>if (foo >= bar) baz();
</code></pre>
<p>But let's say sometimes baz(); needs to be run when <code>foo <= bar</code>, or <code>foo == bar</code>... and let's say that this comparison operator is grabbed from, say, a db table, and placed into a variable: <code>$param = ">="</code>.</p>
<p>Is there any way you could modify the first line to use <code>$param</code>, besides a switch-case with multiple if statements?</p>
<p>In my code, <code>baz();</code> spans about a whole bunch of lines, and would become an organizational nightmare were I to manage it by hand.</p>
| php | [2] |
5,323,547 | 5,323,548 | Jquery counters & variables and square brackets | <p>A form with this hidden field is loaded</p>
<pre><code><input type = "hidden" class = "counter" value="6">
</code></pre>
<p>I use Jquery to do this</p>
<pre><code>var counter = $(".counter:last").val()
</code></pre>
<p>then a click event adds a row with this text field</p>
<pre><code>.append($('<input>').attr('type', 'text').attr('name', 'drugName["+counter+"]')
</code></pre>
<p>this returns</p>
<pre><code> <input size="40" type="text" name="drugName["+counter+"]">
</code></pre>
<p>Where am I going wrong. I tried multiple variations.</p>
<p>Any help/references?</p>
| jquery | [5] |
1,528,930 | 1,528,931 | What is the most Word-like ASP.NET custom control that you can buy? | <p>We are looking to implement a rich-text box in an ASP.NET application and our requirements are specific to using the "Track Changes" features of Microsoft Word. The closest thing we found in the RadEditor by Telerik. This is a nice control that has a "Track Changes" button and will give you the ability to track the changes from the text in the box to now. It does not let you track your changes from the two previous versions. </p>
<p>We have used CVSWeb in the past and the display was not great but it did have the ability (in a web page) to diff two different versions of text (source code in this case). </p>
<p>Does anyone have any experience or know of any web-based diff tools that work nicely with a rich-text editor in the web?</p>
| asp.net | [9] |
35,848 | 35,849 | Can I overload the conditional operator in C#? | <p>I did go through <a href="http://stackoverflow.com/questions/9428577/how-to-overload-the-conditional-operator">this</a> and <a href="http://stackoverflow.com/questions/4421706/operator-overloading/4421715#4421715">this</a> before actually posting this. But those are for C++. Do the same things apply on C# as well? And the second link I have provided states that conditional operator cannot be overloaded, I didn't see the reason why(assuming the same applies on C# as well). Can someone provide links for further reading, or just clarify the matter?</p>
<p>EDIT:</p>
<p>I'm not onto any actual scenario where I would need to overload this operator, but I was just curious as to why it can't be overloaded. Is it just because there isn't any actual possible situation where such overloading could provide any significant functionality?</p>
| c# | [0] |
2,340,188 | 2,340,189 | What are the side effects of breaking the prototype chain in javascript? | <p>We write a lot of JavaScript code to run our automated testing using a tool called TestComplete. In several cases I've set up inheritance trees using the following syntax:</p>
<pre class="lang-js prettyprint-override"><code>function Parent()
{
...
//some inline code here executes on object creation
}
Child.prototype = Parent;
Child.prototype.constructor = Child;
function Child()
{
Parent.call(this);
...
}
</code></pre>
<p>The reason I've used</p>
<pre><code>Child.prototype = Parent;
</code></pre>
<p>instead of</p>
<pre><code>Child.prototype = new Parent();
</code></pre>
<p>is because there is code that is executed on the creation of a new object in the parent in some cases. Setting the prototype this way has never been an issue, in that I've always been able to call all the functions defined in the Parent after having created a Child.</p>
<p>I suspect, however, I've actually broken the prototype chain in doing this and I've been saved by the fact that all the methods we define are defined inline (ie. inside the constructor function) and not using the object.prototype.method = ... syntax, and so the fact the chain is broken has gone unnoticed.</p>
<p>So I have two questions; have I broken the chain, and what are the side effects of breaking the prototype chain in JavaScript?</p>
| javascript | [3] |
3,768,176 | 3,768,177 | What is the major difference between GridView/DetailsView/FormView in ASP.net | <p>GridView/DetailView/FormView will be used for displaying tabular data.
Let me know about what are the differences these three also where we use?</p>
| asp.net | [9] |
5,346,168 | 5,346,169 | Searching within a webpage | <p>what would be the best way to write a code in Php that would search within a webpage for a number of words stored in a file? is it best to store the source code in a file or is it another way? please help.</p>
| php | [2] |
5,493,719 | 5,493,720 | How to save values when i click previous button in asp.net | <p>I have created online exam application (web based) in asp.net c#. In my application first form includes dropdownlist for tests & start button. When i select particular test from dropdownlist & after clicking to start button it goes to the next page. It includes one label for question, radiobuttonlist for answers, next & previous button.In first form in the click event of start button i have created non repeated random values ( for question ids) i.e stored in array.when it redirects to another page then 1st question from that array will display with answers & after clicking next button next question will appear, here i have inserted selected values(answers selected in radiobuttonlist) by user in database to calculate score. Problem is with previous button, when i click to previous button then it goes to previous button but i want earlier selected values by user to be bind with that radiobuttonlist. how i can do this? </p>
| asp.net | [9] |
4,467,515 | 4,467,516 | How to not populate contents inside a given div | <pre><code><body>
<div id = "container1" >
<div id = "x1" />
<div id = "x2" />
<div id = "x3" />
</div>
<div id = "container2" >
<div id = "Y1" />
<div id = "Y2" />
<div id = "Y3" />
</div>
<div id = "container3" >
<div id = "Z1" />
<div id = "Z2" />
</div>
</body>
$('body div').each(function(i) {
if($(this).attr('id')!='container2') { //This is only for div container2 & not for elements inside it
console.log(i);
}
});
</code></pre>
<p>I don't want the elements within a particular div say container2 to be populated how can this be done..
in above code it populates the div's inside container2</p>
| jquery | [5] |
1,146,531 | 1,146,532 | What is the Java equivalent of C++'s const member function? | <p>In C++, I can define an <em>accessor</em> member function that returns the value of (or reference to) a private data member, such that the caller cannot modify that private data member in any way.</p>
<p>Is there a way to do this in Java?</p>
<p>If so, how?</p>
<p>I know about the <code>final</code> keyword but AFAIK, when applied to a <em>method</em> it:</p>
<ol>
<li>Prevents overriding/polymorphing
that method in a subclass.</li>
<li><strike>Makes that method inline-able.</strike> (see comment by @Joachim Sauer below)</li>
</ol>
<p>But it doesn't restrict the method from returning a reference to a data member so that it can't modified by the caller.</p>
<p>Have I overlooked something obvious?</p>
| java | [1] |
3,462,391 | 3,462,392 | how to search like LIKe operator in sql in hash map in java | <p>I want to search a hash map depending on the user input. Suppose a user give value 'A',I have to display starting with A company name and if user give value 'AB' I have to display starting with AB company name. I am storing company name in hash map</p>
| java | [1] |
1,058,202 | 1,058,203 | asp.net : is it possible to Split large ASP.NET pages into pieces? | <p>Is it possible to split large ASP.NET-pages into pieces? JSP has the <a href="http://java.sun.com/products/jsp/tags/11/syntaxref1112.html" rel="nofollow">jsp:include</a> directive. Is there any equivivalent in ASP.NET</p>
<p>I'm not interested in reusing the pieces. I just want to organize the HTML/ASP code.</p>
<p>Isn't User Controls and Master Pages overkill for doing this?</p>
| asp.net | [9] |
5,237,669 | 5,237,670 | Retrieve the 30th word of a web page? | <p>I was just wondering if what to do or is this even possible if I want to retrieve the 30th word of a web page. It can be the 25th or any number but my dilemma is about on how to do this. Is this even possible? Thank you.</p>
| php | [2] |
737,254 | 737,255 | os and os version detection in javascript | <p>how i can detect that my visitor using which os and os version in javascrtip . for example windows vista or seven or Xp and linux too . </p>
| javascript | [3] |
5,417,778 | 5,417,779 | How to rewrite if (...) to switch about identifying dynamic class type? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/708911/using-case-switch-and-gettype-to-determine-the-object">Using Case/Switch and GetType to determine the object</a> </p>
</blockquote>
<p>If I hope to rewrite my codes with syntax if (...) else if (...) into the syntax with switch (...) case for following codes, how to achieve it ?</p>
<pre><code>void Foo(object aObj) {
if (aObj is Dictionary<int,object> ) {
} else if (aObj is string) {
} else if (aObj is int) {
} else if (aObj is MyCustomClass) {
} else {
throw new Exception("unsupported class type.");
}
}
</code></pre>
| c# | [0] |
2,018,715 | 2,018,716 | jQuery $(html, props) (DOM creation) ignores props map | <p>I'm unable to correctly create DOM elements using jQuery (1.3.2):</p>
<pre><code>var ev_t;
$("#add-event").click(function() {
ev_t = $("<form>", { action : "someURL" }).hide().appendTo(document.body);
var fields = $("<div>").appendTo(ev_t);
fields.load("someURL", function() {
$("<input>", { type: "submit", value: "Add" }).appendTo(ev_t);
ev_t.dialog();
});
ev_t.submit(function() {
// form submission ...
return false;
});
return false;
});
</code></pre>
<p>The and elements are inserted but <strong>none of the attributes</strong> (form action and input type and value) <strong>are set</strong>. What am I doing wrong?</p>
| jquery | [5] |
16,953 | 16,954 | C# Form Question | <p>I have written a App that uses a simple form to collect some data from the user. What is the easiest way of making this data availbel to all the classes outside the form? </p>
<p>Thanks</p>
<p>Daniel </p>
| c# | [0] |
226,223 | 226,224 | PHP: Server duplicating $_SESSION['Name'] data to '$Name' variable | <p>I've just discovered a setting on the server I'm developing a site for that is different from my localhost settings, however, I can't track down where to change it.</p>
<p>Here's a simple example of what's happening.</p>
<pre><code>$_SESSION['Animal'] = "Dog";
echo "#1: ".$_SESSION['Animal']."<br/>";
echo "#2: ".$Animal;
</code></pre>
<p>On my localhost, the server returns:</p>
<blockquote>
<p>#1: Dog<br>
#2:</p>
</blockquote>
<p>On the public host, the server returns:</p>
<blockquote>
<p>#1: Dog<br>
#2: Dog</p>
</blockquote>
<p>I'm guessing this is a setting in the public servers php.ini file, however, I cannot locate which setting it is.</p>
| php | [2] |
2,149,437 | 2,149,438 | Looping over filenames in python | <p>I have a zillion files in a directory I want a script to run on. They all have a filename like: prefix_foo_123456_asdf_asdfasdf.csv. I know how to loop over files in a directory using a variable in the filename in shell but not python. Is there a corresponding way to do something like</p>
<pre><code>$i=0
for $i<100
./process.py prefix_foo_$i_*
$i++
endloop
</code></pre>
| python | [7] |
2,035,384 | 2,035,385 | Forward declaration and inheritence | <p>The following code generates an error in the <code>getFoo</code> function because <code>MockFoo</code> hasn't yet been defined as being inherited from <code>IFoo</code>. How can I fix this? The simplest way is to change <code>_foo</code>'s type to IFooPtr. But I'd prefer not to make this change if possible. I can't change the order the classes are defined in.</p>
<pre><code>class MockFoo;
typedef boost::shared_ptr<MockFoo> MockFooPtr;
class MockBar: public IBar
{
virtual IStructPtr getFoo() const {
return _foo;
}
...
MockFooPtr _foo;
};
class MockFoo: public IFoo
{
...
};
</code></pre>
| c++ | [6] |
4,465,756 | 4,465,757 | How to send broadcast message using c# application | <p>I have some C# form application.I'm using some central data base which is developed on SQLServer2005.According to my application there are several user levels such as admin,reception,...</p>
<h2>problem</h2>
<p>There is a requirement that if someone has changed the database(eg: add new record/delete record) that will be noticed admin and higher level of user.</p>
<p>What will be the way that should I follow to achieve this task!</p>
<p>Thank in advance!</p>
| c# | [0] |
845,320 | 845,321 | how to learn Java | <p>This question I am asking because I couldn't find any source which gives complete overview of java development. I just want to know where java technology currently in market & what is preferable for development !</p>
<p>Java always remain top programming language for development point of view. However, java is combo of, j2ee, j2me, jsp, jsf, spring, other frameworks, ui components, jndi, networking tools and various other "J" are there !</p>
<p>However, learning java is definitely dependent on the development requirement, but still, to be a well-experienced java developer, what is the organised way of learning java? What is preferable in current technology ? and what is deprecated, currently ?</p>
| java | [1] |
5,272,876 | 5,272,877 | Inheritance best practice : *args, **kwargs or explicitly specifying parameters | <p>I often find myself overwriting methods of a parent class, and can never decide if I should explicitly list given parameters or just use a blanket <code>*args, **kwargs</code> construct. Is one version better than the other? Is there a best practice? What (dis-)advantages am I missing?</p>
<pre><code>class Parent(object):
def save(self, commit=True):
# ...
class Explicit(Parent):
def save(self, commit=True):
super(Explicit, self).save(commit=commit)
# more logic
class Blanket(Parent):
def save(self, *args, **kwargs):
super(Blanket, self).save(*args, **kwargs)
# more logic
</code></pre>
<p><strong>Perceived benefits of explicit variant</strong></p>
<ul>
<li>More explicit (Zen of Python)</li>
<li>easier to grasp</li>
<li>function parameters easily accessed</li>
</ul>
<p><strong>Perceived benefits of blanket variant</strong></p>
<ul>
<li>more DRY</li>
<li>parent class is easily interchangeable</li>
<li>change of default values in parent method is propagated without touching other code</li>
</ul>
| python | [7] |
2,948,325 | 2,948,326 | Using PHP to clean up a url | <p>I have the following line of PHP:</p>
<p><code>echo "<li>".str_replace("http://", "", rtrim($row['website'],"/"))."</li>";</code></p>
<p>That removes the http:// and the trailing slash from a url. However I also want it to remove https:// but don't want to wrap it in another str_replace.</p>
<p>Is their a better and more efficient way of doing this? Thanks</p>
| php | [2] |
5,625,501 | 5,625,502 | Why does Response.Write("<someting>") not work in ASP.NET code-behind? | <p>I have this code in my ASP.NET code-behind file:</p>
<pre><code>Response.Write("<someting>")
</code></pre>
<p>But it doesn't work. If I remove the <code><</code> tag delimiter, then it writes the content to the page. </p>
<p>My question is: how can I write an XML string to the page from a code-behind?</p>
| asp.net | [9] |
5,064,667 | 5,064,668 | Searching through Dictionaries in Python | <p>I would like to search through on one of the components in a dictionary <code>"C"</code>.</p>
<p>For that component I have around 6 pairs of (x,y,z). I would like to search through until there are no more and assign the integers to a variable: <code>x_value</code>, then the <code>y</code> and then the <code>z</code>.</p>
<pre><code>Guanine = {"C": [(6.958, -5.037, 2.040), (7.355, -4.850, 3.500),
(6.601, -5.985, 4.170), (6.713, -7.099, 3.130),
(5.627, -8.157, 3.190), (4.259, -1.254, 0.410),
(4.530, -2.553, 0.900), (4.456, -4.566, 1.600),
(5.830, -2.919, 1.170), (6.712, -0.955, 0.570)]}
</code></pre>
<p>For example:</p>
<pre><code>Atom type: X-value: Y-Value: Z-Value:
C 6.958 -5.037 2.040
C2 6.601 -5.985 4.170
etc...
</code></pre>
<p>I want to do this until there is no more value.</p>
| python | [7] |
946,216 | 946,217 | Draw a box on an image, javascript only? | <p>What i want to do is have a user upload his image. When its complete it will display the image on the same page w/o refreshing. Here is the part i need to figure out, how do i have the user select a box in the image? so i can crop it when the user is done? (using ImageMagick).</p>
<p>If possible i would like a border for the user to stretch to edit the width and height. Then click within the rect to move around.</p>
| javascript | [3] |
28,283 | 28,284 | I want to set image and also text on tab | <pre><code>TabSpec spec1 = tabHost.newTabSpec("Tab1");
spec1.setIndicator("Tab1", getResources().getDrawable(R.drawable.news) );
Intent in1 = new Intent(this, Act1.class);
spec1.setContent(in1);
</code></pre>
<p>I did use this code.but when i using this code the image not show on the tab only text are showing.so please tell me any suggestion.and this code only for one tab.</p>
| android | [4] |
5,474,571 | 5,474,572 | How can I use the icon in android expander_ic_maximized | <p>Can you please tell me how can I use android's icon expander_ic_maximized?
I find that in frameworks/base/core/res/res/drawable-hdpi/expanderic_minimized.9.png</p>
<p>Here is my layout xml file:</p>
<pre><code><ImageView android:id="@+id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/expander_ic_minimized">
</code></pre>
<p>But I get this error:</p>
<pre><code>res/layout/test.xml:70: error: Error: Resource is not public. (at 'src' with value '@android:drawable/expander_ic_maximized').
</code></pre>
| android | [4] |
4,927,370 | 4,927,371 | What is the best javascript barcode generator? | <p>I need to generate a I25 barcode using javascript only. Looking for a good, reliable, cross-browser javascript component.</p>
| javascript | [3] |
1,543,854 | 1,543,855 | Loaders and LoaderManager | <p>I am learning loaders and loadermanager with an example. My main activity has a dynamically added two fragmnets. The fragmnets uses loadermanager callback method to query the sqlite database. can i use common loader in activity for two fragnents or should i use AsyncLoader ?</p>
| android | [4] |
4,742,357 | 4,742,358 | How is it that I could compile an exe in C# with no error but execution fails with dll not found? | <p>I have created a console app referencing <a href="http://www.antlr.org/download/CSharp" rel="nofollow">http://www.antlr.org/download/CSharp</a></p>
<pre><code>using System;
using Antlr.StringTemplate;
using Antlr.StringTemplate.Language;
</code></pre>
<p>That I want to compile by command line with</p>
<pre><code>csc /r:c\antlr\antlr.runtime.dll;c\antlr\StringTemplate.dll myprog.cs
</code></pre>
<p>It created the exe but when executing it says it cannot find StringTemplate or dependencies why ? I have all dll package in same directory.</p>
<p>Update: the same program build under visual studio works but I need to do this by command line.</p>
<p>Update 2: even copied to exe path it still can't find them weird !</p>
<p>Update 3: ok finally works I confused visual studio bin output and my csc output dir.</p>
| c# | [0] |
4,645,236 | 4,645,237 | Show Menu Option Automatically At First Activity Of Application | <p>I develop a application</p>
<p>and in which i have a Menu option which i invoke from onCreateOptionMenu()</p>
<p>But this is called only when any user press the menu button</p>
<p>so now i want that my application start and first Activity is Welcome.java</p>
<p>then in onCreate(Bundle b)</p>
<p>can i write sone line from which the menu is invoked automatically without pressing Menu button</p>
<p>i used openOptionMenu() but it not works.</p>
<p>2) can i create a Button and simulate it as Menu button and then write button.performClick() so it act as a Menu Button and menu option will visible</p>
<p>So give me some suggestion on this</p>
<p>Thanks</p>
| android | [4] |
2,436,673 | 2,436,674 | How to access static members of outer class from an inner class constructor? | <p>How to get this to work:</p>
<pre><code>class ABC(object):
C1 = 1
class DEF(object):
def __init__(self, v=ABC.C1):
self.v = v
a = ABC()
</code></pre>
<p>From the inner class DEF, I cannot access the constant "C1". I tried with "ABC.C1" and "C1" alone but to no avail.</p>
<p>Please advise.</p>
| python | [7] |
3,876,713 | 3,876,714 | How would i set two coordinates for two different words on screen? | <p>I want to set two different coordinates for two words.
Im using <code>COORD pos = {20,20}</code> for one word
i tried using </p>
<pre><code>COORD position = {10,10}
SetConsoleCursorPosition(screen, pos)
cout << "word A" << endl
SetConsoleCursorPosition(screen, position)
cout << "word B" << endl
</code></pre>
<p>for the other but no luck </p>
| c++ | [6] |
984,021 | 984,022 | Package adding on device | <p>How i can detect package adding on device using service and after it get package name? </p>
| android | [4] |
2,325,154 | 2,325,155 | Local DB in javascript + html5 | <p>My local database values are cleared when i cleared the browsing data in google chrome.</p>
<p>Could you tell me , how to fix it </p>
<p>Regards</p>
<p>Ravindran</p>
| javascript | [3] |
3,008,874 | 3,008,875 | Java script validation symbol % must not allow in text field | <p>I am working in javascript. I want to add validation on my text field that only characters are allowed.</p>
<p>along with characters, I allowed left arrow key which has keycode 37. But this is creating problem because keycode of % is also 37. And I dont want to allow % symbol.</p>
<p>Please suggest me how can I differenciate % and left arrow key , because both key code are 37 ?</p>
| javascript | [3] |
2,299,091 | 2,299,092 | Android App Promotional Graphics | <p>I am looking for a picture of an android phone that I can overlay my apps screen shots in for promotional purposes. For iOS apps apple provided you with images to use for this purpose. Is there a similar set of images we can get somewhere on the Android side?</p>
| android | [4] |
1,732,999 | 1,733,000 | check to see if div is empty issue | <p>i want to check if the div is empty if so i want to add text 'empty' to it. </p>
<p>What am i doing wrong? Thanks SO!</p>
<p><a href="http://jsfiddle.net/HuWUV/" rel="nofollow">js Fiddle File</a></p>
<p><strong>HTML</strong></p>
<pre><code><div class="staff-row">
<img alt="" src="foo.jpg" />
<h2>Lorem Ipsum! FOOO!</h2>
<p>Lorem Ipsum</p>
</div>
<!-- eo : staff-row -->
</code></pre>
<p><strong>jQuery</strong></p>
<pre><code>$('.staff-row').mouseenter(function() {
if ($('.staff-row').is(':empty')) {
$('.staff-row').text('empty');
} else {
$('.staff-row').text('full');
}
});
</code></pre>
| jquery | [5] |
1,839,216 | 1,839,217 | how to open the url from a .pdf file through xcode programming | <p>i'm trying to get the url from a pdf files so that if a user double taps the url on the pdf file, it opens in a new web page.... how can i do it ? any suggestions ? i'm using Xcode 3.2 version.</p>
| iphone | [8] |
3,756,269 | 3,756,270 | Why "is_zipfile" function of module "zipfile" always returns "false"? | <p>As per the python documentation <a href="http://docs.python.org/2/library/zipfile#zipfile.is_zipfile" rel="nofollow"><code>zipfile.is_zipfile(filename)</code></a> function returns True if filename is a valid ZIP file else False.</p>
<p>I have written my script as below and initially passed one argument and get "False" as result, But for other valid arguments also I am getting <code>False</code> all the time.</p>
<h3>Script:</h3>
<pre><code>import zipfile
for filename in [ r'D:\Python_Programs\B1', r'D:\Python_Programs\B2', r'D:\Python_Programs\B1+B2\20130105\144145_1.zip', 'NEWS.txt']:
print (filename, zipfile.is_zipfile(filename))
</code></pre>
<h3>Result:</h3>
<pre><code>D:\Python_Programs\B1 False
D:\Python_Programs\B2 False
D:\Python_Programs\B1+B2\20130105\144145_1.zip False
NEWS.txt False
</code></pre>
<p>Can anyone help me out why I am getting False every time??</p>
| python | [7] |
4,566,585 | 4,566,586 | Setting the tabIndex of the label generated by asp:listitem | <p>If I create a radio button group like this:</p>
<pre><code><asp:radiobuttonlist ID="rbListHeader" runat="server" RepeatDirection="Horizontal" Font-Size="12px" TabIndex="-1">
<asp:listitem value="London" />
<asp:listitem value="Newcastle" />
</asp:radiobuttonlist>
</code></pre>
<p>the html that is rendered includes a html label for each radio button. This label displays next to the radio buttons and displays either 'London' or 'Newcastle' on the screen. I have the TabIndex of the radiobuttonlist set to -1 but tabbing through the form the focus moves to the 'London' label. As this label seems to be auto generated, is there any way of setting the TabIndex of the generated labels to -1?</p>
| asp.net | [9] |
5,884,512 | 5,884,513 | Access to __init__ arguments | <p>Is is possible to access the arguments which were passed to <code>__init__</code>, without explicitly having to store them?</p>
<p>e.g.</p>
<pre><code>class thing(object):
def __init__(self, name, data):
pass # do something useful here
t = thing('test', [1,2,3,])
print t.__args__ # doesn't exist
>> ('test', [1,2,3])
</code></pre>
<p>The use-case for this is creating a super-class which can automatically store the arguments used to create an instance of a class derived from it, <em>without</em> having to pass all the arguments explicitly to the super's <code>__init__</code>. Maybe there's an easier way to do it!</p>
| python | [7] |
5,062,763 | 5,062,764 | Creating a (moveable) grid | <p>What is the best way to create a movable/scalable grid? I currently use JQuery and Raphael, but I want to keep it as small as possible. My current method works as follows:</p>
<p>On each move/resize:
- Calculate width/height
- Remove all previous gridlines
- Create (Width / Grid size) vertical lines (SVG)
- Create (Height / Grid size) horizontal lines (SVG)</p>
<p>Is there a more effective way?</p>
| javascript | [3] |
1,286,275 | 1,286,276 | Purpose of classical approach | Relationship to object state | <p>There is a library written purely using objects literals to group similar items. This is some what related to having public static classes. For example</p>
<pre><code>var public_statics = {
var1 : 'hello',
func1 : function(){//stuff}
};
</code></pre>
<p>I see that people write OO ( or similar) JavaScript by emulating classes or simply using new on JavaScript function objects.</p>
<p>In web(I've heard this on SO and experienced it), it seems there is not much state. What I mean by this, is you never seem to have 2 different objects from the same "class". </p>
<p>For example I have a UserNew model "class" in which it is only possible to have one model at any given time. In fact all of my models are this way, there is only one instance at any given time.</p>
<p>Are there any examples of state-full applications ( where you instantiate multiple objects )?</p>
<p>Am I perhaps building out this library wrong if all the models are collections of public statics using object literals?</p>
<p>I can post any code that might be relevant.</p>
| javascript | [3] |
711,774 | 711,775 | jquery find element with html | <p>Let's say I have some html that looks like this:</p>
<pre><code><div id="TheTable">
<div class="TheRow">
<div class="TheID">123</div>
<div class="TheQuantity">2</div>
<div class="TheName">test1</div>
</div>
<div class="TheRow">
<div class="TheID">456</div>
<div class="TheQuantity">3</div>
<div class="TheName">test2</div>
</div>
</div>
</code></pre>
<p>And let's say I have 1,000 rows.</p>
<p>I'm writing a function that takes in an ID as parameter and that searches for the TheQuantity and TheName values in the html. Something like this:</p>
<pre><code>function GetData(TheID) {
var TheIndex = $('#TheTable').find("the index of the row that contains TheID")
TheQuantity = $('#TheTable .TheQuantity').eq(TheIndex);
TheName = $('#TheTable .TheName').eq(TheIndex);
}
</code></pre>
<p>I could loop through each .TheID and return the index like this:</p>
<pre><code> $('#TheTable .TheRow').each( function () {
if ($(this).html() === TheID) { return $(this).index(); }
});
</code></pre>
<p>but I'm wondering if there's a more direct way of doing it. Let me know if you have some suggestions.</p>
<p>Thanks.</p>
| jquery | [5] |
5,787,498 | 5,787,499 | Javascript Launch Popup and Fill a text field | <p>I am struggling with this, hope something can shed some light. </p>
<p>On click of a button, I want to open a popup window, and transfer data from parent window to a text field in the popup. And, ensure popup is fully loaded before data is filled.</p>
<p>I tried using document.ReadyState=="complete", but it fires before the popup is fully loaded. I also tried to check the popup.body in a setTimeOut method, but to no avail. </p>
<p>Can you please help ?</p>
<p>PS: Popup window is a form from another domain !.</p>
| javascript | [3] |
5,050,936 | 5,050,937 | It works well even if I delete JavaScript:void(0), why? | <p>The following code is from 'JavaScript by Example Second Edition',the window will be colsed when I click "Click here to close little window".</p>
<p>I find it works well too even if I replace href="JavaScript:void(0)" with href="", why ? </p>
<p>Thanks!</p>
<pre><code><html>
<head><title>Display Form Input</title>
<script type="text/javascript">
function showForm(myform) {
NewWin=window.open('','','width=300,height=200');
name_input="<b>Your name: " + myform.user_name.value
+ "</b><br />";
NewWin.document.write(name_input);
phone_input="<b>Your phone: " + myform.user_phone.value
+ "</b><br />";
NewWin.document.write(phone_input);
}
function close_window(){
NewWin.window.close();
}
</script>
</head>
<body><hr><h3> Display form data in a little window</h2><p>
<form name="formtest">
Please enter your name: <br />
<input type="text" size="50" name="user_name" />
<p>
Please enter your phone: <br />
<input type="text" size="30" name="user_phone" />
</p><p>
<input type="button"
value="show form data"
onClick="showForm(this.form)"; />
</form>
</p>
<big>
<a href="JavaScript:void(0)" onClick="close_window()">
Click here to close little window</a>
</big>
</body>
</html>
</code></pre>
| javascript | [3] |
19,840 | 19,841 | Is there anyway to set a timeout for a file_exists or any other function? | <p>I am running a website where we are serving a large amount of files from a folder mounted over Fuse (cloudfuse - a Rackspace Cloudfiles container), it works wonderfully most of the time however every now and again the Fuse connection stalls and all my Apache processes hang waiting for a file_exists() function to return.</p>
<p>My question, is there anyway to set a timeout for a specific function or to use another function to check if the file exists but return with false if function takes longer than x seconds?</p>
| php | [2] |
159,839 | 159,840 | Is it possible to have an "alias" for byte array in C#? | <p>I want to call an overloaded callback method that can accept several different types as possible arguments.</p>
<pre><code>string s = "some text";
PerformCallback(s);
int i = 42;
PerformCallback(i);
byte[] ba = new byte[] { 4, 2 };
PerformCallback(ba);
</code></pre>
<p>So far no problem. But now I want to have two different kinds of byte arrays, let's call them blue byte arrays and green byte arrays. The byte arrays themselves are, well, just byte arrays. Their blueness and greeness is only a philosophical concept, but I'd like to write an overloaded callback method that has two different overloads for the two kinds of byte arrays, and a way of invoking the two different overloads. I'd prefer very much to avoid having to use an extra argument to indicate the color of the byte arrays, and I'd prefer to avoid anything that adds an enclosing class or similar that will add runtime overhead. </p>
<p>Any ideas? Thanks in advance.</p>
| c# | [0] |
4,003,773 | 4,003,774 | is there a maximum android.os.Message.obj size? | <p>I'm using Messages to return the HTML/XML/etc. from my "Communicator" service to some Activity in my App.</p>
<p>This is working great at the moment - but I worry: How big can the HTML get before this system breaks down?</p>
<p><strong>note:</strong> I checked the documentation at <a href="http://developer.android.com/reference/android/os/Message.html" rel="nofollow">http://developer.android.com/reference/android/os/Message.html</a> but I don't see any max size warnings.</p>
<p>Maybe someone has a personal experience to answer this question.</p>
| android | [4] |
5,334,998 | 5,334,999 | Dynamic Dropdown Div Using Jquery | <p>I need a snippet of code for creating an "other" dropdown option. Basically, if there are 3 options for color: red|green|blue, I want them to have the ability to select other and when selected a div appears with a textbox for them to enter the next color. Posting code now....sorry people. Here is what I have tried so far:</p>
<pre><code><label class="desc">
Operating System:
</label>
<div><select name="os" id="os"><option value="1" selected = "selected">Windows 98</option>
</code></pre>
<p>Windows ME
Create New
</p>
$(document).ready(function(){
$('#os').change(function(){
if($(this).val() == 'other')
$('#otheros').show();
else
$('#otheros').hide();
});
});
| jquery | [5] |
3,415,812 | 3,415,813 | Android activity Button | <p>I have two buttons in my first android frame. ok button and cancel button. Cancel button will terminate the application. I want another button which appears in a new frame after I click on ok. I used setOnClickListener. But that button instead of appearing on a new frame after I click ok, appears in the same frame as Ok exists ,under cancel. I even created a new Button in main.xml and a new activity in AndroidManifest.xml. should I write them in a special way? I don't know exactly that what can be the problem. please help me.</p>
| android | [4] |
2,026,279 | 2,026,280 | cannot import mainactivity because the project in use | <p>I am trying to import the file in eclipse.</p>
<pre><code>New->import->browse(for the path)->select the project->finish.
</code></pre>
<p>I followed the same way but it's not working. I received the error </p>
<pre><code>Cannot import MainActivity because the project name is in use
</code></pre>
| android | [4] |
2,495,572 | 2,495,573 | elif statement getting a syntax error | <p>I'm trying to set up a menu. In the menu, the user is able to pick which option to take and then add or delete items from a list. I'm having trouble with the syntax in my elif statement. it's saying there is a syntax error and highlighting the second elif. I'm not sure what the problem is. </p>
<pre><code>choice = int(input('Enter your choice: '))
if choice !=0:
display_menu()
elif choice == 1:
add_value = float(input('Add value: ')
elif choice == 2:
delete_value_by_value = float(input('Which value would you like to delete?
</code></pre>
| python | [7] |
490,323 | 490,324 | Is there a way/tool to check memory leak of Cocoa Touch project? | <p>Is there a way/tool to check memory leak of Cocoa Touch project?
or
I need to write the codes by myself.</p>
<p>Thanks</p>
<p>interdev</p>
| iphone | [8] |
1,325,077 | 1,325,078 | IE issue with Jquery methods | <p>I am having trouble getting an ID of an element. The codes work in FF and chrome but not IE.
Can anyone help me about it? Thanks a lot</p>
<pre><code><td id='tdID'>
<img id='test' src='a.jpg' class='imgClass' />
</td>
</code></pre>
<p>jquery</p>
<pre><code>$('.imgClass').click(function(){
ip=$(this).parent().attr('id');
//undefined in IE
console.log(ip);
})
</code></pre>
| jquery | [5] |
4,188,902 | 4,188,903 | How can i implement button.setOnClickListener and button.setOnTouchListener simultaneously | <p>i am working on android.</p>
<p>i am creating a login button. i want that whenever i press login button then text color of that button should be changed. </p>
<p>and when this button pressed then login functionality should be performed.</p>
<p>for this i am coding like this:-</p>
<pre><code>button_login.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View arg0, MotionEvent arg1) {
// TODO Auto-generated method stub
int action = arg1.getAction();
if(action == MotionEvent.ACTION_DOWN) {
button_login.setTextColor(Color.parseColor("#163D74"));
return true;
} else if (action == MotionEvent.ACTION_UP) {
button_login.setTextColor(Color.parseColor("#FFFFFF"));
return true;
}
return false;
}
});
button_login.setOnClickListener(new Button.OnClickListener() {
@Override
public void onClick(View v)
{
// checking the functionality of login
}
});
</code></pre>
<p>but only onTouchListener is working. login functionality is not working.</p>
<p>please suggest me what mistake i have done. and how can i implement these both functionalities. means how can i change the color of text of button and how can i perform login functionality.</p>
<p>Thank you in advance.</p>
| android | [4] |
241,610 | 241,611 | Is there a static constructor or static initializer in Python? | <p><strong>Is there such a thing as a static constructor in Python?</strong> </p>
<p>How do I implement a static constructor in Python?</p>
<p>Here is my code... The <code>__init__</code> doesn't fire when I call App like this. The <code>__init__</code> is not a static constructor or static initializer.</p>
<pre><code>App.EmailQueue.DoSomething()
</code></pre>
<p>I have to call it like this, which instantiates the App class every time:</p>
<pre><code>App().EmailQueue.DoSomething()
</code></pre>
<p>Here is my class:</p>
<pre><code>class App:
def __init__(self):
self._mailQueue = EmailQueue()
@property
def EmailQueue(self):
return self._mailQueue
</code></pre>
<p>The problem with calling <code>__init__</code> every time is that the App object gets recreated. My "real" App class is quite long. </p>
| python | [7] |
1,435,496 | 1,435,497 | Is Python2.6 stable enough for production use? | <p>Or should I just stick with Python2.5 for a bit longer?</p>
| python | [7] |
2,001,320 | 2,001,321 | reinterpret signed long as unsigned in Python | <p>A 64-bit number is unpacked by <a href="http://msgpack.org/" rel="nofollow">msgpack</a> as signed; how can I reinterpret it as unsigned?</p>
| python | [7] |
3,801,394 | 3,801,395 | Can Application Context be changed during application lifecycle? | <p>Can I rely on statement the Application's <code>Context</code> is not changing during application's lifecycle? What if I store a <code>context</code> somewhere using singleton pattern and then use wherever I need?</p>
| android | [4] |
5,422,569 | 5,422,570 | App won't install but runs fine in emulator | <p>How can I diagnose apk install issues? I have an app that compiles and runs in the emulator without any issues. But as soon as I export and try to load on my phone, it fails to install with no error to point me in the right direction.</p>
| android | [4] |
4,393,095 | 4,393,096 | Perform an action when near the bottom of the page | <p>Javascript code:</p>
<pre><code>var next_page = 2;
var next_previews = 36;
function ajax_autopaginate(a, b) {
function incrementPage () {
next_page += 1;
next_previews += 36;
}
jQuery('#' + b).load(a , function() {
incrementPage();
setTimeout(pollScrollPosition, 500);
});
}
function pollScrollPosition() {
var y = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop;
var max = window.scrollMaxY || (document.body.scrollHeight - document.body.clientHeight);
if ((max - y) <= 1500) {
ajax_autopaginate('http://www.wallpaperup.com/welcome/get_wallpapers/date_added/DESC/' + next_previews + '/','content' + next_page);
} else {
setTimeout(pollScrollPosition, 500);
}
}
setTimeout(pollScrollPosition, 500);
</code></pre>
<p>I'm using this code to execute a function if we are 1500px or less from the end of the page, all works good in Firefox, but in IE and Chrome the function is always executed, how should I fix it?</p>
<p>this is the page that gives me problems: <a href="http://www.wallpaperup.com/" rel="nofollow">http://www.wallpaperup.com/</a></p>
| javascript | [3] |
4,024,967 | 4,024,968 | How can i use JSR 172 in Android? | <p>i want to use JSR 172 API in android.But supports core java,is it possible to use JSR 172 in android.Please give some code snippets or suggests any web sites to learn about it.</p>
| android | [4] |
5,406,556 | 5,406,557 | ListViewitem -textview in leftside and right side i want number of contents inside particular item | <p>in ListViewitem i want textview in leftend and in rightend i want number of contents inside particular item ex:i have jj,kk,ll are text in lists and contents are 3,4,5 respectively.i want in listview as jj 3, kk 4,ll 5 in listview</p>
| android | [4] |
5,462,338 | 5,462,339 | How to create my own QR Generator in Android? | <p>I want to create an application where i can create my own QR barcode and then also the barcode scanner to decode it? anybody know of any tutorials or links to code which this is available? thanks </p>
| android | [4] |
1,130,740 | 1,130,741 | jquery undo a function bind | <p>I am using the following with an address picker.</p>
<p>HTML</p>
<pre><code><form>
<input id="searchByLoc" type='checkbox' >
<input id="searchQuery" type='text' >
<input type="submit' value="search">
</form>
</code></pre>
<p>JQuery:</p>
<pre><code>$('#searchByLoc:checkbox ').live('change', function(){
if($(this).is(':checked')){
var addresspicker=$(this).addresspicker();//alert('checked');
} else {
//I want to un initialize the addresspicker() on the input field
var addresspicker=die($(this).addresspicker());//alert('un-checked');
}
});
</code></pre>
<p>I am having some trouble with the ELSE part above. If the check box is unchecked, how can I stop the initialization so that no location is suggested?</p>
| jquery | [5] |
909,286 | 909,287 | How to pickle a empty file? | <p>I want to pickle a file that sometime's is empty. Right now its empty, but my idea is that its going to grow over time.</p>
<p>How do i check if a file is "pickable" since it seems that you can not pickle a empty file?</p>
| python | [7] |
2,969,237 | 2,969,238 | Can i set variable as the initalization style after initalization? C# | <p>I can do this</p>
<pre><code>var v = new class_name() { media_id = m, fn = fullfn2 };
</code></pre>
<p>Can i do something like this</p>
<pre><code>set v { media_id = m, fn = fullfn2 };
</code></pre>
| c# | [0] |
5,394,415 | 5,394,416 | How best to structure class heirachy in C# to enable access to parent class members? | <p>I am having a couple of issues deciding how best to describe a certain data structure in C# (.NET 3.5).</p>
<p>I have to create a class library that creates some text files for the input of a command line program. There are dozens of file types, but most of them have a similar header, footer and a couple of other properties. </p>
<p>So a file might look like this:</p>
<pre><code>timestamp filename company
....lots of attributes that make up the file body....
footerdetail1 footerdetail2 footerdetail3
</code></pre>
<p>Now out of these dozens of file types there are really only three unique header/footer combos. </p>
<p>So I want to make a parent class that contains most of the headerItems and footeritems, and then implement the actual file types in a derived class:</p>
<pre><code>class BaseFileType {
public List<HeaderItems>;
public List<BodyItems>;
public List<FooterItems>;
FileType filetype;
String filename;
public BaseFileType1 (FileType filetype,String filename) {
this.filetype = filetype;
this.filename = filename;
// add stuff to the header list
// add stuff to the footer list
}
// some methods to find items in the header/ footer lists
}
class ActualFile1 : BaseFileType {
ActualFile() {
//add stuff to the bodyitems list
}
//some other generic methods
}
</code></pre>
<p>The thing is, I want to inherit the contructor from the base class for the derived class, but from what I have read this can not be done. What is the best strategy here? </p>
<p>I have seen that I can call the base constructor from my derived class constructor like so:</p>
<p>ActualFile() : base (parent parameters)</p>
<p>Is this even the best way to go about my task? In the end I am just looking for the best data structures for all of this file information so I dont need to repeat myself when I make these classes. </p>
<p>What other alternatives to people thing would work? Have a single FileFactory that spits out classes containing the structure I require?</p>
| c# | [0] |
4,718,512 | 4,718,513 | cURL scraping functions | <p>Can you enlighten me with your knowledge about cURL? I tried cURL but the output of the function is it copies the whole site. I plan to just gather all the search results of that site.</p>
<p>How can I achieve this?</p>
| php | [2] |
4,131,750 | 4,131,751 | how to avoid "duplicate class" in Java | <p>Suppose I have have a java project <code>myProject</code> and am using an external library jar (<code>someJar.jar</code>), which has a class <code>com.somepackage.Class1.class</code>.</p>
<p>Now I find an updated version of <code>Class1.java</code> which fixes a bug in the original jar.</p>
<p>I include the new <code>Class1.java</code> in my source code under package <code>com.somepackage</code></p>
<p>When I build the project (e.g., using Netbeans), there is a <code>dist\myProject.jar</code> which contains the class<code>com.somepackage.Class1.class</code> and a <code>dist\lib\someJar.jar</code> which also contains a class with the same name.</p>
<p>When I run the file (e.g, using <code>java -jar dist\myProject.jar</code>), the new version of <code>Class1.class</code> is used (as I want). </p>
<ol>
<li><p>How does Java decide which class file to run in case of such duplicates? Is there any way I can specify precedence ?</p></li>
<li><p>Is there any 'right' way to avoid such clashes? </p></li>
<li><p>In Proguard, when I try to compress my code, I get a <code>duplicate class</code> error. How do I eliminate this?</p></li>
</ol>
| java | [1] |
913,190 | 913,191 | Which licenses are required for developing an iPhone application? | <p>I see two possible licenses you might need for iPhone application development. The Company Developer and the Enterprise Developer. When might I need one or the other or both?</p>
| iphone | [8] |
247,115 | 247,116 | Making on onClick to change text in javascript | <p>I want to make a format like the following:</p>
<p>Phrase<br>
[Button]</p>
<p>When the button is clicked, the 'phrase' changes and the button remains. I am able to make it so text appears, however I can not make it so the button stays. Does anyone have an idea of how this may be done? Thanks.</p>
| javascript | [3] |
5,369,186 | 5,369,187 | What is the technology behind Dailymile.com | <p>What is the technology behind Dailymile.com? Does it use PHP or Ruby?</p>
<p>Thanks!</p>
| php | [2] |
5,128,696 | 5,128,697 | How do i show the image as selected on touch of a particualr image? | <p>I am using image adapter along with grid view to display certain images with caption. </p>
<p>After user touch an image then press a button this image is loaded on the next screen.
Right now when a user touch an image it does not show as being selected. </p>
<p>I want to know is there a way to show selected image after a user touch a particular image.</p>
<p>Please help me on this</p>
<p>Thanks</p>
<p>Pankaj </p>
| android | [4] |
3,252,667 | 3,252,668 | Grouping drawables by screen size instead of density | <p>I've read this article <a href="http://developer.android.com/guide/practices/screens_support.html" rel="nofollow">Supporting Multiple Screens</a>, but still don't get one thing and need an advice.</p>
<p>I have 3 psd files which contains design for 240x320, 480x800 and 720x1280 screen resolutions. </p>
<p>Since I don't know densities, looks like I should group drawables by screen size. I'm right?
I'm confused, because app should support tablets (which usually are mdpi) and hdpi phones. Or it's not correct design files?</p>
| android | [4] |
3,262,314 | 3,262,315 | How do I transfer a value from a text box to a new window using Javascript? | <p>I have created a form so the user can complete his name, last name, credit card number etc.</p>
<p>All the information is provided by the user.</p>
<p>When the user has ended his work he should press a button and a new window pops up with the user's information revised.</p>
<p>Anyone has a suggestion on this? I would be grateful.</p>
| javascript | [3] |
4,105,446 | 4,105,447 | Use Strict : How to test it? | <p>I have been reading people recommending using "use strict" option. As mentioned <a href="http://www.nczonline.net/blog/2012/03/13/its-time-to-start-using-javascript-strict-mode/?utm_source=javascriptweekly&utm_medium=email" rel="nofollow">here</a></p>
<p>every major browser supports strict mode in their latest version, including Internet Explorer 10 and Opera 12. I wanted to test it with IE10 and i have following code segemnt. IE 10 /FF did not gave any error message. What am i missing ? How do i test that "use strict" is actually working if i make any mistake ?</p>
<pre><code><html>
<head>
<script type = "text/javascript">
"use strict";
function doSomething(value1, value1, value3) {
alert('hello');
}
</script>
</head>
<body>
hello
</body>
</html>
</code></pre>
| javascript | [3] |
5,337,346 | 5,337,347 | Android FBReaderj - The import org.geometerplus.fbreader.filetype cannot be resolved | <p>I have just got the latest (1.5.5) FBReaderj from Github (https://github.com/geometer/FBReaderJ)</p>
<p>After running ant release (successfully) I created a new android project from existing sources into eclipse and I now face 3 errors in different files all stating "The import org.geometerplus.fbreader.filetype cannot be resolved"</p>
<p>The offending line of code is this</p>
<pre><code>import org.geometerplus.fbreader.filetype.*;
</code></pre>
<p>I have looked in the relevant folder and sure enough there are no files named filetype. anything</p>
<p>So where do I get these files from and what should be in them?</p>
| android | [4] |
2,752,106 | 2,752,107 | Error javascript can not get value from attribute value | <pre><code>$(document).ready(function(){
$('.submit').click(function(){
var value = $('#Name').attr('value');
alert(value);
});
});
<input type="text" value="10" id="Name"/>Hello world
<input type="submit" class="submit" value="submit"/>
</code></pre>
<blockquote>
<p>Result is "Hello World", I want get value is "10", how to fix it ?</p>
</blockquote>
| jquery | [5] |
1,011,810 | 1,011,811 | Error when accessing webservice through proxy internet connection | <p>I have created a .net windows application ,in that i need to get information from server via webservice. if my internet connection through proxy then thrown error ERROR: Could not resolve host: ws.audioscrobbler.com; No data record of requested type .if its direct connection everything work fine.Please help me to resolve this. </p>
| c# | [0] |
125,995 | 125,996 | Connecting Android application with a webservice | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/5952449/about-android-button-event">About Android button event</a> </p>
</blockquote>
<p>Hi
i am developing an android application which has the following feature :</p>
<p>Spinner1:Showing some currency e.g:US $, Pound etc
Spiner2:Showing some currency e.g:US $, Pound etc</p>
<p>Three button:
Clean
Swap
Convert</p>
<p>anybody have any idea how i run my application using a web service?
i need code.</p>
| android | [4] |
3,884,183 | 3,884,184 | "Sourcing" a Python file from another | <p>I have a service where users upload egg files. The problem is that a <code>settings.py</code> file needs to be extracted by me and I should only accept some of the values in that file. The file consists of regular Python variables like:</p>
<pre><code>VAR1 = 'Hello'
VAR2 = ['my.list']
VAR3 = {
'a': 'b'
}
</code></pre>
<p>I need to extract these variables in a good manner and I have looked for a way to 'source' (Bash term I suppose..) the <code>settings.py</code> file to my worker Python file to extract the variables. I haven't found a way to do that when searching. Any ideas?</p>
<p><strong>My (specific) solution</strong></p>
<pre><code># Append path to sys.path
sys.path.insert(0, os.path.dirname('/path/to/settings.py'))
import settings as egg_settings
LOGGER.info('Settings: VAR1 = %s', egg_settings.VAR1)
# Remove from sys.path
sys.path.pop(0)
</code></pre>
| python | [7] |
1,786,359 | 1,786,360 | Android scrolable table layout | <p>What are the basic steps to add a scroll bar into table layout in programmatically? Not using XML,
I've tried this:</p>
<pre><code>TableLayout MainLayout = new TableLayout(this);
ScrollView scview=new ScrollView(this);
scview.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));
scview.addView(MainLayout);
MainLayout.setHorizontalScrollBarEnabled(true);
</code></pre>
<p>But this is not working. It gives error...</p>
| android | [4] |
3,821,667 | 3,821,668 | Equivalent of fgets (c langauage) in android | <p>I want to read a line from a text file. In c <code>fgets()</code> in used. Is any equivalent of <code>fgets()</code> in android.</p>
| android | [4] |
5,330,174 | 5,330,175 | Displaying button inside componentsJoinedByString | <p>i have a question that i want to put a button instead of @"/n" ie,@"uibutton"</p>
<pre><code>BibleIphoneAppDelegate *appDelegate = (BibleIphoneAppDelegate *)[[UIApplication sharedApplication] delegate];
NSArray *allVerses = [appDelegate.biblearray valueForKey:@"verseNumber"];
_bibleDesciption.text = [allVerses componentsJoinedByString:@"/n"];
</code></pre>
<p>verseNumber contains verses of the bible ,my need is to put a button in between verses.I hope u understand my question.plase help me to do this.
Thanks in advance.</p>
| iphone | [8] |
5,192,838 | 5,192,839 | Can push notification be sent without an alert for certain actions? | <p>I know you can register to have alerts or not when you call the push notification API. However my problem is that I want a certain class of actions to have an alert notification while no alert notification for other class of action? </p>
<p>So for example, an alert should be shown when we send the notification "Heart rate dropping alert!". But no alert should be shown when we send the notification "downloading updated patient data", the app should just take the notification as an instruction to being download if it is launched. And simply ignore it if it is not launched.</p>
<p>How to implement this?</p>
| iphone | [8] |
1,526,404 | 1,526,405 | Can't load my app on the Samsung galaxy prevail and I try settings and unkonw source | <p>Can't load the app i made on the Samsung galaxy prevail and I try goning to settings and unkonw source but it still not showing up on the avd manager in eclispe and i was try development USB debugging but that just have it chage the battey. it work on one of my friends evo</p>
<p>thank you</p>
| android | [4] |
5,918,223 | 5,918,224 | android take phone screen shot pro-grammatically, outside of the app? | <p>I want to take a screen shot of my phone pro-grammatically, when the user touch some of the key in the phone.Also i want to save the image somewhere..Can anyone help me ?</p>
| android | [4] |
5,523,783 | 5,523,784 | Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource | <pre><code> $keyword = $_POST['keyword'];
$start_time = getmicrotime();
$result = mysql_query(" SELECT p.page_url AS url,
COUNT(*) AS occurrences
FROM page p, word w, occurrence o
WHERE p.page_id = o.page_id AND
w.word_id = o.word_id AND
w.word_word = \"$keyword\"
GROUP BY p.page_id
ORDER BY occurrences DESC
" );
$end_time = getmicrotime();
$result1 = mysql_fetch_array(mysql_query($result));
</code></pre>
| php | [2] |
528,549 | 528,550 | When I take screenshot, How to remove the button? | <p>When I take screenshot, How to remove the button? I am using this code for screen shot</p>
<pre><code>CGImageRef originalImage = UIGetScreenImage();
CGImageRef videoImage = CGImageCreateWithImageInRect(originalImage, CGRectMake(0, 66, 320, 230));
UIImage *snapShotImage = [UIImage imageWithCGImage:videoImage];
UIImageWriteToSavedPhotosAlbum(snapShotImage, nil, nil, nil);
CGImageRelease(originalImage);
CGImageRelease(videoImage);
</code></pre>
<p><img src="http://i.stack.imgur.com/TEdxC.png" alt="enter image description here"></p>
| iphone | [8] |
6,023,956 | 6,023,957 | if a class in its constructor contains an int,, and an array.. how can i use the array in another class.? | <pre><code>class C()
{
num =4;
int[] a = new int[5];
}
</code></pre>
<p>in a new class if i called C </p>
<pre><code>C c1 = new C();
</code></pre>
<p>how can i use array a..??</p>
| java | [1] |
2,396,745 | 2,396,746 | Android: How does dp work, and can I test it? | <p>I was wondering, I now have an app that makes a grid of 16x16 buttons which are all 30dp wide. That makes a total of 480dp. In the emulator it runs fine (which runs at WVGA). Can I change the screen size of the emulator in any way to test if my app runs fine on lower and higher screen resolutions?</p>
| android | [4] |
2,012,773 | 2,012,774 | Excel Reading Problem with Column having multiple types | <p>I am Reading Excel File in .Net Framework 1.1 , using C# . I am getting problem in reading Excel file when i have column which contains number as well text something like this</p>
<p>1003 1004 1005 Test_1 Test_2</p>
<p>Its not giving me any error, but i am getting null values in first three row.
This is the code that i am using to read excel file.</p>
<pre><code>string strcon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +
path +
";Extended Properties=Excel 8.0;";
System.Data.OleDb.OleDbConnection objConn = new System.Data.OleDb.OleDbConnection(strcon);
try
{
objConn.Open ();
System.Data.OleDb.OleDbDataAdapter objadp = new System.Data.OleDb.OleDbDataAdapter("Select * from [" + sheetName + "$" + "]",objConn);
DataSet ds = new DataSet ();
objadp.Fill (ds);
return ds;
}
catch(Exception ex)
{
throw ex;
}
finally
{
objConn.Close();
objConn.Dispose();
}
</code></pre>
<p>can anybody tell me what can be a problem? Thanks.</p>
| c# | [0] |
5,579,294 | 5,579,295 | C++ store any child struct/class in array? | <p>In C++ I have a series of structures defined...</p>
<pre><code>struct Component {};
struct SceneGraphNode : Component {};
struct Renderable : Component {};
struct Health : Component {};
</code></pre>
<p>These could easily be classes, I've been told that there is very little difference in C++.</p>
<p>In Java it is possible to declare an array of type <code>Component</code> and put any class that extends from (inherits) <code>Component</code> into it. Java considers them all components and since everything uses smart pointers, Java's "array" is really just a list of smart-pointers which are all the same size. </p>
<p>However I understand that Java handles arrays significantly different from C++. When I checked the size of each of these structs I got the following. </p>
<pre><code>Component // 4
SceneGraphNode : Component // 8
Renderable : Component // 8
Health : Component // 20
</code></pre>
<p>Which isn't suprising. Now when I create an array of Components, the size of the blocks are obviously going to be 4 (bytes) which won't hold any of the other structures.</p>
<p>So my question is, how can I store a loose list of <code>Components</code> (IE a list that can store any class / struct that inherits from Component)? In Java this is mind-numbingly simple to do. Surely there must be an easy way in C++ to do it. </p>
| c++ | [6] |
5,491,682 | 5,491,683 | Jquery gallery slider | <p>Hi will some one help me to find a free script something like this website has</p>
<p><a href="http://www.paris-beyrouth.org/" rel="nofollow">http://www.paris-beyrouth.org/</a></p>
| jquery | [5] |
177,054 | 177,055 | Android execution error in AVD | <p>an anyone look at this simple code (?) and tell me what's wrong please?
I'm a complete beginner to android development and I don't understand why my application doesn't even start. I get an unexpected error.. : (
Here it is:</p>
<pre><code>package applicationTest.ppr.com;
import android.app.Activity;
import android.os.Bundle;
import android.widget.LinearLayout;
public class MainClass extends Activity {
/** Called when the activity is first created. */
/*Global vars*/
public static LinearLayout lila;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
lila = (LinearLayout) findViewById(R.id.lilay);
setContentView(lila);
}
public void Shortoast(){new Game(this);}
public static LinearLayout returnLayout(){return lila;}
}
</code></pre>
<p>The program doesn't even launch, and I think it might have something to do with how I handle the LinearLayout and setContentView();</p>
<p>anyway thanks very much in advance!</p>
| android | [4] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.