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
3,195,295
3,195,296
How to secure NSUserDefaults?
<p>Apple advise using NSUserDefaults to store all your app preferences. However, it seems that NSUserDefaults is very easily editable. Is there a way to secure this. I'm not looking for a way to make it impossible to edit, just making it harder so that users won't be so tempted to change application internal variables. </p>
iphone
[8]
743,108
743,109
Window pane hanging/freezing on resizing
<p>The pane is a child of CHtmlView. The pane is docked via Codejock XTP panemanager.</p> <p>If I don't load help (.chm) into the pane it doesn't freeze at all. But when it's loaded the document is navigational and works fine.</p> <p>While it's hanging, if I alt-tab to another window and then come back it stops hanging, but no re-size change occurs.</p> <p>Sorry I can't be more specific. Any thoughts of what could be wrong or where I should look?</p> <p>Thanks</p>
c++
[6]
4,353,732
4,353,733
Execute a batch file in C#
<p>I have a batch file which basically downloads a file from a site or returns a error message saying files are not available. I want to execute this .bat file in C#(SSIS script component) and save the file name to a variable(if the file is downloaded) or assign the error message to the variable.</p> <p>Thank you in advance</p>
c#
[0]
81,424
81,425
reading bytes from binary file to long int
<p>I have two question :</p> <ul> <li><p>I have a data on binary file. I want read first 8 bytes to signed long int by using read function but I could not . Do you know how can I do that ? </p></li> <li><p>How can directly read a block of data to string ? Can I read like as shown in ex : </p> <pre><code> ifstream is; is.open ("test.txt", ios::binary ); string str ; is. read ( str.c_str, 40 ) ; // 40 bytes should be read </code></pre></li> </ul>
c++
[6]
5,040,570
5,040,571
Back Button With Javascript
<p>when i hit back button in browser it should navigate to desired location,</p> <p>but the code written below works for all the buttons including the 'form' buttons</p> <pre><code>window.onbeforeunload = function () { location.replace('http://www.google.com'); return "This session is expired and the history altered."; } </code></pre> <p>how i can restrict this functionalty to browsers back button alone</p> <p>thanks</p>
javascript
[3]
2,417,589
2,417,590
Align UITableViewCell accessoryView to bottom of cell instead of middle
<p>In the native Mail app, the To: field has a ContactAdd UIButton on the right in the accessoryView position, but it is aligned to the bottom of the cell (which you can see as the cell grows in height). Is it possible to mimic this using the accessoryView property? As far as I can tell, accessoryViews always align in the middle.</p>
iphone
[8]
2,047,862
2,047,863
What is the correct Ordering of this Javascript Array?
<p>In Firefox the output is ordered Alphabetically (which is the order they are declared). In IE and Chrome they are numerical. All latest versions.</p> <p>Which is correct?</p> <pre><code>&lt;html&gt; &lt;head&gt;&lt;/head&gt; &lt;body&gt; &lt;script type="text/javascript"&gt; function makeArray() { var array = [{5:'Five',4:'Four',1:'One',3:'Three',2:'Two'}]; var msg = ''; for (var val in array[0]) { msg = msg + val; } alert(msg); } &lt;/script&gt; &lt;input type="button" onClick="makeArray();" value="Press Me" /&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Back Story... In <a href="http://www.inflectra.com/SpiraTeam/" rel="nofollow">SpiraTeam</a> (Our current bug tracking system) many of the lists (users, modules, etc) are ordered using a similar format to the above. This makes finding stuff very hard and annoying unless you use FireFox. My interest is purely academical, I only ask because I want to know which browser's correct.</p>
javascript
[3]
5,722,631
5,722,632
How can I group arrays into one array in php?
<p>I would like to convert / form the following arrays as example:</p> <pre><code>Array ( [product_category] =&gt; for-women ) Array ( [brand] =&gt; 7-diamonds ) Array ( [size] =&gt; 12 ) Array ( [color] =&gt; 882536 ) </code></pre> <p>Into one array that just merges each array pair and put them altogether :</p> <pre><code>Array ( [product_category] =&gt; for-women [brand] =&gt; 7-diamonds [size] =&gt; 12 [color] =&gt; 882536 ) </code></pre> <p>I tried array_merge and it didn't work. The array out put in my code is from $_SESSION which returns an array (a pair key=> value) like this:</p> <pre><code>foreach($_SESSION as $k =&gt; $v) { if (strstr($k, 'saved_query_') == true) { $saved = array_merge($v); } } </code></pre> <p>So I get each array by looping through session which has a query, the result is array pair, I want to combine all pairs found (Do not know how to use array_merge in that case).</p> <p>I tried array_combine and array_merge they do not seem like the functions I need based on php manual: </p> <p><strong>array_combine — Creates an array by using one array for keys and another for its values</strong></p> <p>Which I do not want to do, I just want to copy/move small arrays in one array, without changing any pairing/key/value.</p>
php
[2]
178,753
178,754
Google Adsense clash with SSL certificate
<p>When I add the below AdSense script to my SSL secure page it shows crossed red mark when browsed using chrome. When I remove this adsense script my SSL works great and perfect. Confused why the SSL does not accept even if I use https secure external link</p> <pre><code>&lt;script type="text/javascript" src="https://pagead2.googlesyndication.com/pagead/show_ads.js"&gt; </code></pre>
jquery
[5]
3,799,865
3,799,866
how to redirect to particular URL while clicking on button in android?
<p>i want to redirect to particular URL while clicking on button</p>
android
[4]
4,358,699
4,358,700
Android: ADB not loading
<p>When I want to create android project I get the following message. I cant proceed anyway. Please anybody help me. My system is ubuntu 10.10</p> <p>Failed to get the adb version: Cannot run program "/home/mak/Android/Android SDK/android-sdk-linux_x86/platform-tools/adb": java.io.IOException: error=13, Permission denied</p>
android
[4]
493,359
493,360
Show an animated progressbar GIF image in android
<p>I have a Splash Screen for an Android Project in which I have to add a progress bar for 5 seconds but the problem is that the screen's background is white and our progress bar doesn't displayed on that, due to this reason I downloaded a progress bar GIF image which is not animating in Android, So the question is that How am I able to animating GIF progress bar file on my Splash Screen.</p> <p>Please suggest me the right solution regarding the same.</p> <p>Thanks in advance.</p>
android
[4]
1,379,338
1,379,339
setting up a RadioGroup programmatically
<p>I'd like to create a custom <code>View</code> which contains a <code>RadioGroup</code>. Inside of the <code>RadioGroup</code> I'd like the <code>RadioButtons</code> to be set up so that the first <code>RadioButton</code> is at the top left, the 2nd one is below that, the third to the right of the 1st one and the 4th one underneath that. In other words, I want to create a group where the radiobuttons are laid out in a square of sorts. I think if I set the orientation of the group to be vertical, then all the radiobuttons will be in a straight line. If, on the other hand, I set the orientation to horizontal, then, again, the radiobuttons will all be in a straight line, going horizontal. Is there a way to do what I want or am I forced to set up two separate <code>RadioGroups</code>, both to horizontal orientation?</p>
android
[4]
1,277,119
1,277,120
Getting ID of all elements of a certain class into an array
<p>Here's what I'm trying to do:</p> <p>Currently I am using this to create an array of all elements matching the class name of <code>.cookie</code>. Right now I am getting the text value of that element, which is not what I need:</p> <pre><code>var getAllCookies = $('.cookie').text(); var cookiesArray = jQuery.makeArray(getAllCookies); alert(cookiesArray[0]); </code></pre> <p>What I need is to find all elements of a certain class (.cookie), get that element's ID value and store that ID value inside of array. </p>
jquery
[5]
3,464,476
3,464,477
count down timer in php
<p>I would like to ask some idea or solutions on how to make a count down timer in PHP. My page automatically refresh every minute using meta refresh so client side count down timer not needed. so server side PHP is what I am looking.</p> <p>so here's the scenario.</p> <blockquote> <p>Last answer was 2012-01-02 10:00:00, the next answer should be 2012-01-02 10:45:00.</p> </blockquote> <p>It means that it needs to add 45 mins from the last answer. from the current time let say for example 2012-01-02 10:05:00, so the count down timer will show 40 mins left for the next answer. if the timer becomes 0, it will show you lose. then user will answer it then another count down from the last answer added with 45 mins.</p>
php
[2]
272,852
272,853
Is it possible to access static methods of a class by multiple object instances simultaneously?
<p>Example:</p> <pre><code>ThisClass.staticMethod(Object... parameters); </code></pre> <p>will be accessed by multiple instances of other objects and simultaneously.</p> <p>Will there be any dependencies with this other objects when they are using the same static method at the same time?</p>
java
[1]
1,210,464
1,210,465
What does [System.SerializableAttribute()] do
<p>I am looking at somebody elses C# code and before a public enum there are the following lines:</p> <pre><code>[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)] [System.Xml.Serialization.XmlRootAttribute(Namespace="", IsNullable=false)] </code></pre> <p>Can somebody explain in plain english what each of these lines are doing.</p>
c#
[0]
1,922,974
1,922,975
How to manually read from iPhone preferences?
<p>I just wrote a few values to my user preferences using <code>NSUserDefaults</code>. Is there a way I can go in and examine the persisted preferences file manually (when running on the simulator) to make sure they were written properly?</p>
iphone
[8]
4,780,572
4,780,573
Access modifiers for inner classes
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/595179/protected-public-inner-classes">protected/public Inner Classes</a> </p> </blockquote> <p>I am sure the question has been asked already, but I wasn't able to find one so I'll ask...</p> <p>I am curious what is the difference between private(protected) and public inner class. I am able to use both from out of the containing class using the outer class object.</p> <pre><code>public class A{ private class B{ } public static void main(String[] args){ A a = new A(); B b = a.new B(); } } </code></pre>
java
[1]
2,537,298
2,537,299
C++ Singleton Creation Problem
<p>I recently acquired some code that I want to port to Linux. In a header file though, I have some curious code that I hope someone can shed some light on. Within a header file, inside a namespace where other classes are defined, I have the following:</p> <pre><code>#define CREATE_SINGLETON_METHODS(s) \ private: \ friend class Singleton&lt;c&gt;; \ ##c(); \ virtual ~##c(); </code></pre> <p>I understand that the <code>##</code> is the token pasting operation, but I can't figure out why the original author (who I don't know, and can't contact) used it. I have an implementation class that looks like this:</p> <pre><code>class MapManager : public Singleton&lt;MapManager&gt; { CREATE_SINGLETON_METHODS(MapManager) private: ... </code></pre> <p>When I compile, I get the following error:</p> <p><code>error: pasting ";" and "MapManager" does not give a valid preprocessing token</code></p> <p>This compiles find on Windows and some earlier versions of gcc (pre 4.x). Any ideas as to what could be going on here? Thanks!</p>
c++
[6]
2,716,913
2,716,914
C++ Passing a pointer to a member function as an argument
<p>I need to pass a pointer to a member function as an argument to a member function in another class. What I'm doing is something like below. I want to call int Processor::AddJob(void <em>(</em>_pFunc)(void*), void* _pArg) method with void* ProcessHandler::Task(void* a) as the first argument. I did it as </p> <pre><code>TaskFunc pFunc1 = &amp;ProcessHandler::Task; p_Processor-&gt;AddJob(pFunc1,10); </code></pre> <p>But it gives the error </p> <blockquote> <p>error: no matching function for call to Processor::AddJob(void* (ProcessHandler::<em>&amp;)(void</em>), int)’ Processor.h:47: note: candidates are: int Processor::AddJob(void* (<em>)(void</em>), void*)</p> </blockquote> <p>Can someone please help me on this.My implementation is as follows.(Not the exact code-it is much larger than this)</p> <pre><code>class Processor { public: Processor(); virtual ~Processor(); int AddJob(void *(*_pFunc)(void*), void* _pArg); }; int Processor::AddJob(void *(*_pFunc)(void*), void* _pArg) { //Job addition related code goes here } ///////////////////////////////////////////////////////////////////////////// typedef void* (ProcessHandler::*TaskFunc)(void*); class ProcessHandler { public: ProcessHandler(Processor* _pProcessor); virtual ~ProcessHandler(); void* Task(void* a); void Init(); private: Processor* p_Processor; }; void* ProcessHandler::Task(void* a) { //Task related code goes here } void ProcessHandler::Init() { TaskFunc pFunc1 = &amp;ProcessHandler::Task; p_Processor-&gt;AddJob(pFunc1,10); //This give the compile error. } ///////////////////////////////////////////////////////////////////////// int main() { Processor* pProcessor = new Processor(); ProcessHandler* pProcessHandler = new ProcessHandler(pProcessor); pProcessHandler-&gt;Init(); } </code></pre>
c++
[6]
5,622,576
5,622,577
NsdManger.DiscoveryListener(): how to flush the cache
<p>I have device which will broadcast itself once connected to the AP (through mDNS). But the strange thing is :</p> <p><code>even the device has been plug out for a few 10 minutes, when I retsart the app (so restart the NsdManager too )the Android API NsdManger.DiscoveryListener() still cannot find it's not available anymore (onServiceFound() raise immediately ).</code> </p> <p>it looks like the device's info has been cached by the system. Does anyone know how the NsdManger.DiscoveryListener() works and how to force it to flush the cache? Thanks. </p>
android
[4]
1,362,903
1,362,904
what are the mathematical formulas/concepts used in implementing Chart API (bar chart, pie chart etc.,)
<p>Trying to implement chart API in Java. But I am unsure of the mathematical formulas/concepts used in drawing each of the chart type. Can someone specify the mathematical concepts to be known for drawing each sort of the chart.</p>
java
[1]
1,615,228
1,615,229
processing bitmap files dynamically from folder using c#
<p>camera will capturing image and storing in a folder(.bmp file).simultaneously our application needs to get one by one image file from the folder for processing.(captured images will update the folder dynamically.if we use FileSystemWatcher , it may cause problem for us.(We are selecting the directory before processing of the image,so updated images will not process.is there any solution for this problem)how to get one by one image from the folder at runtime?</p>
c#
[0]
2,723,366
2,723,367
jQuery add a class after fadeOut completly done
<p>Here is the code: </p> <pre><code>&lt;style&gt; #box1, #box2, .container { position: absolute; top: 0px;z-index:10; height: 50px; } #box1 { background-color: #ff0000; width: 100px; left: 200px; } .container { width: 640px; overflow: hidden; height: 50px; background-color:#000; color:#FFF; } &lt;/style&gt; &lt;div class="container"&gt; &lt;div id="box1"&gt;&lt;/div&gt; &lt;/div&gt; &lt;script&gt; var animateMe = function(targetElement, speed){ var position = $(targetElement).position(); var positionA = $(targetElement).position(); if(positionA.left = '400px'){ $(targetElement).fadeIn(1000).css({left:'200px'}); }; //animate $(targetElement).animate( { 'left': '400px' }, { duration: speed, complete: function(){ animateMe(this, speed); } } ).fadeOut(1000); }; $('.container').hover(function(){ animateMe($('#box1'), 2000); }, function(){ $('#box1').stop(); }); &lt;/script&gt; </code></pre> <p>What I want is when hover:</p> <ol> <li><p>fadesIn</p></li> <li><p>animates to right </p></li> <li><p>FadesOut (when fadeOut done resets left position)</p></li> <li><p>then again repeats to number 1.</p></li> </ol> <p>But my code is it resets postition then fadesOut, fadesIn ...</p>
jquery
[5]
2,731,063
2,731,064
Using using with nested namespaces
<p>Is there any reason, why</p> <pre><code>new N1.N2.N3.C(); </code></pre> <p>would compile, but</p> <pre><code>using N1.N2; ... new N3.C(); </code></pre> <p>would not?</p> <p><strong>EDIT</strong></p> <p>Class C is defined in another referenced assembly like this:</p> <pre><code>namespace N1.N2.N3 { class C { } } </code></pre>
c#
[0]
5,924,854
5,924,855
CATransition private api
<p>Just wonder on ios6 @"suckEffect",@"cube",@"oglFlip",@"pageCurl",@"rippleEffect" ,@"pageUnCurl" </p> <p>which one is private and rejected by app store?</p> <p>Your comment welcome</p>
iphone
[8]
3,158,026
3,158,027
Very basic exercise in Virtual functions
<p>Alright, so here's the exercise: You must define three classes. One class named MyNum that contains a variable of type int. Second class called MyString, will be derived from MyNum and contains string. Third-class call MyType and returns a variable of type MyNum. Each class will be set to a constructor function and virtual function called Show. The constructor function of MyType receive a MyNum variable, whereas the function Show of MyType will run the Show function of MyNum. Now, you need set two objects of type MyType and initialize them. Once an object type MyNum and once an object of type MyString.</p> <p>Here's the code:</p> <pre><code>class MyNum { protected int num; public MyNum(int num) { this.num = num; } public virtual void Show() { Console.WriteLine("The number is : " + num); } } class MyString : MyNum { string str; public MyString(string str) { this.str= str; } } class MyType : MyNum { MyNum num2; public MyType(MyNum num) { this.num2 = num; } public override void Show() { base.Show(); } } class Program { static void Main(string[] args) { } } </code></pre> <p>I'm having the following error:</p> <p>Error 1 'ConsoleApplication1.MyNum' does not contain a constructor that takes '0' arguments C:\Users\x\AppData\Local\Temporary Projects\ConsoleApplication1\Program.cs 23 16 ConsoleApplication1</p> <p>Anyone knows why am I having this error? Thanks.</p>
c#
[0]
3,790,394
3,790,395
javascript function vs. ( function() { ... } ());
<p>I have often see expressions such as:</p> <pre><code>(function () { var x = 1; ... }()); </code></pre> <p>How do I interpret it? syntactically, this alone is a anonymous function definition.</p> <pre><code>function() { ... } </code></pre> <p>what the () after that? and why put it in the enclosing ()?</p> <p>Thanks</p>
javascript
[3]
2,133,942
2,133,943
Declaring variables in python
<p>I wanted parse a file to search one word and print next line i have written python script as follows</p> <pre><code>infile = open("s.sdf","r") output = open("sample.txt","w") d = None HD = None HA = None M = None for line in infile: if line.startswith("&gt; &lt;PUBCHEM_COMPOUND_CID&gt;"): d = infile.next().strip() print d elif line.startswith("&gt; &lt;PUBCHEM_CACTVS_HBOND_DONOR&gt;"): HD = infile.next().strip() print HD elif line.startswith("&gt; &lt;PUBCHEM_CACTVS_HBOND_ACCEPTOR&gt;"): HA = infile.next().strip() print HA elif line.startswith("&gt; &lt;PUBCHEM_MOLECULAR_WEIGHT&gt;"): M = infile.next().strip() print M print "%s \t %s \t %s \t %s" %(d,HD,HA,M) output.write("%s \t %s \%s \t %s" %(d,HD,HA,M)) </code></pre> <p>But unfortunately i getting an error as follows</p> <pre><code>None None None None None None None None None None None None None None None None ....... </code></pre> <p>Can anybody tell me how to solve this..</p> <p>Thanks in Advance</p> <p>N</p>
python
[7]
54,705
54,706
Approach for parsing file and creating dynamic data structure for use by another program
<p>All,</p> <p>Background: I have a customer who has some build scripts for their datacenter based on python that I've inherited. I did not work on the original design so I'm sort of limited to some degree on what I can and can't change. That said, my customer has a properties file that they use in their datacenter. Some of the values are used to build their servers and unfortunately they have other applications that also use these values so I cannot change them to make it easier for me. </p> <p>What I want to do is make the scripts more dynamic to distribute more hosts so that I don't have to keep updating the scripts in the future and can just add more hosts to the property file. Unfortunately I can't change the current property file and have to work with it. </p> <p>The property file looks something like this:</p> <pre><code>projectName.ClusterNameServer1.sslport=443 projectName.ClusterNameServer1.port=80 projectName.ClusterNameServer1.host=myHostA projectName.ClusterNameServer2.sslport=443 projectName.ClusterNameServer2.port=80 projectName.ClusterNameServer2.host=myHostB </code></pre> <p>In their deployment scripts they basically have alot of <code>if projectName.ClusterNameServerX</code> where X is some number of entries defined and then <code>do something</code>, e.g.: </p> <pre><code>if projectName.ClusterNameServer1.host != "" do X if projectName.ClusterNameServer2.host != "" do X if projectName.ClusterNameServer3.host != "" do X </code></pre> <p>Then when they add another host (say Serve4) they've added another if statement. </p> <p>Question: What I would like to do is make the scripts more dynamic and parse the properties file and put what I need into some data structure to pass to the deployment scripts and then just iterate over the structure and do my deployment that way so I don't have to constantly add a bunch of if some host# do something. I'm just curious to feed some suggestions as to what others would do to parse the file and what sort of data structure would they use and how they would group things together by ClusterNameServer# or something else. </p> <p>Thanks</p>
python
[7]
2,588,442
2,588,443
else statement not working. how to close loop when nothing is entered?
<p>else statement not working. how to close loop when nothing is entered? suggestions on how to approach?</p> <pre><code>def main(): print "~*~*~*~*~*~ Timbuktu Archery Contest ~*~*~*~*~*~" archerList = [] #list timeList = [] #list2 name = raw_input ("Enter contestants first name: ") s = str(name) archerList.append(name) while name &gt; 0: time = raw_input ("Enter time (in milliseconds) for %s: " % s) timeList.append(time) name = raw_input ("Enter contestants first name: ") s = str(name) archerList.append(name) else: name == "" print "Slowest archer was " , min(timeList) print "Fastest archer was " , max(timeList) </code></pre>
python
[7]
1,312,044
1,312,045
How does this code work for JUnit in JAVA?
<p>I have the following code for JUnit testing:</p> <pre><code>import static org.junit.Assert.assertEquals; import org.junit.Before; import org.junit.Test; public class JUnitHelloWorld { protected String s; @Before public void setup() { s = "HELLO WORLD"; } @Test public void testHelloWorldSuccess() { s = s.toLowerCase(); assertEquals("hello world", s); } // will fail even if testHelloWorldSuccess is called first @Test public void testHelloWorldFail() { assertEquals("hello world", s); } } </code></pre> <p>Now, according to the comment, why will the second method fail even if the first method is called first? isn't the first method changing the value of s to lowercase?</p>
java
[1]
337,700
337,701
Android How to display 1 out of 54 card images in a ImageView
<p>I'm trying to figure out the best way to display 1 of 54 bitmaps in a <code>ImageView</code> . I figured I could load in a bitmap from the assets. But I can't figure out how to size it. When it loads it from the <code>XML</code> file, it chooses 1 of 3 different bitmaps, each a different size. </p> <p>I can't figure out how to determine what size bitmap to use. I know how to get the width and height of a View, but not the whole screen. Is there a way to get the screen resolution?</p> <p>All so I know how to set the bitmap property of a <code>ImageView</code>, but I could not find anything for scaling. Is there a way to scale it, or will I need a separate bitmap for different screen sizes?</p> <p>This seems like it should be simple, but turning into something very complicated,</p> <p>Is there a way to get the screen resolution? Can I scale the bitmap a <code>ImageView</code> displays? Is there a more easy way to do this?</p>
android
[4]
1,099,088
1,099,089
WinForm App Data Persistance (C#)
<p>I beleive the best ways of "variable short term" persistance in an ASP.NET application are:</p> <ol> <li>Sessions Variable (Session Scope)</li> <li>Application Variable (Application Scope)</li> <li>Page View (Page Scope)</li> <li>Application Settings (Application Scope)</li> <li>???</li> </ol> <p>What are the best ways of "variable short term" persistance in a windows form application for:</p> <ol> <li>Form Scope</li> <li>User Session Scope</li> <li>Application Global Scope</li> </ol> <p>Thanks</p>
c#
[0]
655,657
655,658
Where to put the separation between a stateful object and a stateless calculation in Python?
<p>Which of the following code snippets is the most "pythonic"? The calculation is trivial in this example but could be assumed to be complex in real life.</p> <pre><code>class A(object): """Freely mix state and calcs - no good I presume""" def __init__(self, state): self.state = state def calc_with_state(self, x): return (self.state + x)**2 </code></pre> <p>or</p> <pre><code>class B(object): """Separate state from calc by a static method""" @staticmethod def inner_calc(u, v): return (u + v)**2 def __init__(self, state): self.state = state def calc_with_state(self, x): return B.inner_calc(self.state, x) </code></pre> <p>or</p> <pre><code>class C(object): """Break out the calculation in a free function""" def __init__(self, state): self.state = state def calc_with_state(self, x): return outer_calc(self.state, x) def outer_calc(u, v): return (u + v)**2 </code></pre>
python
[7]
5,809,830
5,809,831
removing row and column from a List of a List c#
<p>I made a matrix from list of list. How can I remove column 'i' and row 'i'? Is there a method for that? I've tried <code>RemoveAt</code> but that'd remove one item.</p> <pre><code>List&lt;List&lt;int&gt;&gt; mtx = new List&lt;List&lt;int&gt;&gt;(); 0 1 2 3 ------- 0|0 0 0 0 1|0 0 0 0 2|0 0 0 0 3|0 0 0 0 </code></pre> <p>For example I would like to delete row i=2</p>
c#
[0]
5,447,918
5,447,919
| operator operation?
<p>(pipe) operator in linq?i want to know operation of operator(|).i want to check multiple columns in different table.In my scenario only single table contain value for that perticular column.</p> <p>my code:</p> <p>&amp;&amp; swr.Date_Of_Event.Date &lt; DateTime.Today.Date | spr.Date_Of_Event.Date &lt; DateTime.Today.Date | scr.Date_Of_Event.Date &lt; DateTime.Today.Date | smr.Date_Of_Event.Date &lt; DateTime.Today.Date</p> <p>In this scenario only one table will contain date value others will contain dault values in their respected columns.</p> <p>The above condition is not working,it takes default value.</p> <p>what condition can i use to get correct value?</p>
c#
[0]
3,757,601
3,757,602
Android change default launcher
<p>I have created my own launcher and I want to replace that with android default launcher. i have remove default launcher from /framework/packages/apps/Launcher2 and placed my launcher with Androi.mk file, After build i got statusbar with no home screen. Please help me out in this.</p> <p>Thank you.</p>
android
[4]
4,833,717
4,833,718
Calculate a div's height with jQuery - minus header and footer
<p>I'm using a sticky footer (negative margin solution) and it works fine. What I need to do is calculate the window's height, subtract the known height of the header and footer then apply that number and use it for the height of the main wrapper div. CSS solutions cause other issues, is there a good way to do this?</p> <pre><code>var h = window.height(); var k = 300; //header is 100px footer is 200px $('#wrap').height(h-k); </code></pre> <p>rough idea, pls help.</p>
jquery
[5]
4,096,899
4,096,900
Animate image opacity from 0 to 100 and back to 0
<p>I have one image which is stacked on top of another one. I am trying to animate the top image opacity to 0 and then back to 100 and then again to 0. This should continue in a loop. Is there a way i can achieve it ?? Please help..</p> <pre><code>$('.bannerHover').animate({ opacity: 0.25 }, 5000, function() { }); </code></pre>
jquery
[5]
4,587,063
4,587,064
After selecting an item from dropdown, display new options and show text?
<p>What I want to do is, have a dropdown list that when you click on a selection, the selection will load new options depending on what you clicked on and as well show text or an image below what you have selected. The only real way I can explain it is with a pic I created.</p> <p>image link here: <a href="http://aionhg.com/images/jsq.png" rel="nofollow">http://aionhg.com/images/jsq.png</a> (I cant post images as I am a new user, understandable)</p> <p>I have been trying to figure it out in JSFiddle here: <a href="http://jsfiddle.net/ZrRZj/1/" rel="nofollow">http://jsfiddle.net/ZrRZj/1/</a></p> <p>Thank you!</p>
javascript
[3]
967,805
967,806
MediaPlayer as a service ignoring volume keys when screen locked
<p>I have a music player service , using a MediaPlayer set to stream type STREAM_RING. It works fine when i change volume pressing the volume keys as long as the screen is not locked or off. How do i set my service to respond to these keys even in locked screen mode? Thanks.</p>
android
[4]
2,362,766
2,362,767
match exact string in a sentence
<p>How to exactly match a given string in a sentence.</p> <p>For example if the sentence is var sentence = "A Google wave is basically a document which captures a communication"</p> <p>and the given string is var inputString= "Google Wave". I need to check the exact presence of Google Wave in the above sentence &amp; return true or false. </p> <p>I tried </p> <pre><code>if(sentence.match(inputString)==null){ alert("No such word combination found."); return false; } </code></pre> <p>This works even if someone enters "Google W". I need a way to find the exact match. Please help</p>
javascript
[3]
2,617,183
2,617,184
Javascript setDate Confusion
<p>I am trying to create a date object that is 90 days from a specified date for use in a date comparison, but am not getting the correct dates. I have isolated my problem to the code shown below.</p> <pre><code>var now = new Date(); var beforeNow = new Date(); var afterNow = new Date(); var myDate = new Date(); var beforeMyDate = new Date(); var afterMyDate = new Date(); beforeNow.setDate(now.getDate() - 90); afterNow.setDate(now.getDate() + 90); myDate.setFullYear(2011, 10, 22); // set to Nov 22, 2011 beforeMyDate.setDate(myDate.getDate() - 90); // set to 90 days before Nov 22, 2011 afterMyDate.setDate(myDate.getDate() + 90); // set to 90 days after Nov 22, 2011 </code></pre> <p>The above is resulting in:</p> <p><em>beforeMyDate</em>: Fri Dec 23 2011 08:46:18 GMT-0800 (Pacific Standard Time)</p> <p><em>myDate</em>: Tue Nov 22 2011 08:46:18 GMT-0800 (Pacific Standard Time)</p> <p><em>afterMyDate</em>: Wed Jun 20 2012 08:46:18 GMT-0700 (Pacific Daylight Time)</p> <p>Here's a fiddle: <a href="http://jsfiddle.net/LnmpR/9/" rel="nofollow">http://jsfiddle.net/LnmpR/9/</a></p> <p>Any help would be appreciated. Thanks.</p>
javascript
[3]
3,074,575
3,074,576
a simple question about casting integers in c++
<p>i have the following very simple code -</p> <pre><code>int x=15000 int z=0.7*x cout&lt;&lt;"z = "&lt;&lt;z&lt;&lt;endl; </code></pre> <p>i get the output</p> <pre><code>z=10499 </code></pre> <p>but if i change it to</p> <pre><code>int z=0.7*15000 cout&lt;&lt;"z = "&lt;&lt;z&lt;&lt;endl; </code></pre> <p>outputs </p> <pre><code>z=10500 </code></pre> <p>i understand it has something to do with z casting the result to int but why is it different in both cases ?</p> <p>thanks,</p> <p>EDIT - i'm using ubuntu's 10.10 GCC build</p>
c++
[6]
4,610,094
4,610,095
Convert our app from java version 6 to 5,
<p>Is there any solution through which I can convert java'a higher application, created in netbeans IDE 6.5.1, into lower version of java version 5. </p>
java
[1]
4,728,792
4,728,793
jQuery append()/appendTo()/html() cause to fire javascript inside DOM
<p>I am working with some legacy software which generates HTML and I need to do some manipulation with this HTML. In order to do so I want to clone all body content to variable and work on it in order to not change anything in browser window. Like this:</p> <pre><code>var tmp = jQuery("body").contents(); </code></pre> <p>Then I try to do some modifications with <em>tmp</em> variable:</p> <pre><code>tmp.wrap("&lt;span&gt;&lt;/span&gt;"); </code></pre> <p>The problem is HTML has &lt;style&gt; and &lt;script&gt; tags in the &lt;body&gt; and it looks like JavaScript fires up when I try to append <em>tmp</em> somewhere, or do wrapping. I'd like to know if there is a way to do $.append, $.appendTo without firing javascript inside of it? (except, filtering actual HTML and removing all &lt;script&gt; tags)</p>
jquery
[5]
5,414,924
5,414,925
how to secure my windows application in C# from piracy without using database?
<p>I am developing a windows application for my client, in .NET Framework 3.5, using C#. There is no need of any database in my application. </p> <p>I want to secure my application by making a registration process at the time of installation, where the user will be asked to enter a registration key, which should be machine dependent, otherwise the user can copy the installation folder and distribute to others, which i don't want to happen.</p> <p>Please suggest me, how to achieve this.</p> <p>Thanks, Bibhu</p>
c#
[0]
1,188,895
1,188,896
Disabling the Android hide keyboard soft button
<p>On a device with a virtual set of hard buttons, is there any way to show the virtual back button instead of showing the virtual close keyboard button when user is interacting with an EditText widget? For example, on the Nexus 7 Android 4.1:</p> <p><img src="http://i.stack.imgur.com/HGETW.png" alt="Screen shot of nexus 7 soft buttons with close keyboard | home | apps"></p> <p>For this dialog, when editing text, I'd rather see:</p> <p><img src="http://i.stack.imgur.com/0nesv.png" alt="Screen shot of nexus 7 soft buttons with back | home | apps"></p> <p>I'd like a dialog I bring up to only allow the keyboard action button -- search in my case -- or the back button to be pressed. It doesn't make sense to hide the keyboard.</p> <p>Edit: as pointed out below, physical back button does same as virtual hide keyboard button when keyboard is open: it closes the keyboard.</p>
android
[4]
4,764,261
4,764,262
How to write 'for-in' in JavaScript ?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/11808758/functional-approach-to-basic-array-construction">Functional approach to basic array construction</a> </p> </blockquote> <p>I am new to js. I just want to know which one is the right approach. Below I have posted my code.</p> <pre><code>var doubles = (i*20 for (i in it)); var doubles ={i*20 for (i in it)}; </code></pre> <p>Thanks</p>
javascript
[3]
589,215
589,216
How to remove unwated code from a php string?
<p>I want replace text in a string using php in-built function, How do I accomplish this?</p>
php
[2]
4,757,510
4,757,511
javafx 2.1 combobox
<p>I used this code to get values from database but can get only one record but I want to put all records in to the combobox.</p> <p>My code is:</p> <pre class="lang-java prettyprint-override"><code>try { stm = db.con.createStatement(); rs = stm.executeQuery("select code from accounts"); while (rs.next()) { for (int i = 1; i &lt;= 5; i++) { ol = rs.getObject(i); } } } catch (SQLException sqlException) { } ObservableList&lt;Object&gt; options = FXCollections.observableArrayList(ol); final ComboBox code = new ComboBox(); code.getItems().addAll(options); </code></pre>
java
[1]
4,199,788
4,199,789
How to extract a specific sentences from html text With php
<p>if i have a big Large html text and i need to extract a specific sentences from it like "/user/abdullaheidtv/videos?sort=dd&amp;view=0&amp;page=1"</p> <p>Perhaps what I need is "/user/abdullaheidtv/videos?sort=dd&amp;view=0&amp;page=<strong><em>12</em></strong>" or "/user/abdullaheidtv/videos?sort=dd&amp;view=0&amp;page=<strong><em>50</em></strong>" or "/user/abdullaheidtv/videos?sort=dd&amp;view=0&amp;page=<strong><em>90</em></strong>"</p> <p>i want to extract Anything Contains "/user/abdullaheidtv/videos?sort=dd&amp;view=0&amp;page=<strong><em>$no</em></strong>"</p> <p>And only the last number is the variable</p> <p>Waiting for help :)</p>
php
[2]
4,542,411
4,542,412
Need to transfer ear file from unix server to local machine using java
<p>I am trying to transfer ear file from Unix server to local machine. But I am not able to get the ear . I am using :</p> <pre><code>JSch jsch = new JSch(); Session session = null; try { session = jsch.getSession("user", "10.213.31.123", 22); session.setConfig("StrictHostKeyChecking", "no"); session.setPassword("pwd"); session.connect(); Channel channel = session.openChannel("sftp"); channel.connect(); ChannelSftp sftpChannel = (ChannelSftp) channel; sftpChannel.get("/osszone/cramer/users/xpi012/JEE/tsrpwl7/WLS/tsrpwl7/servers/CramerServer/stage/CramerServer_CramerAPI/CramerAPI.ear", "C:/sftp"); sftpChannel.exit(); session.disconnect(); } catch (JSchException e) { e.printStackTrace(); } catch (SftpException e) { e.printStackTrace(); } </code></pre>
java
[1]
3,621,521
3,621,522
How can i compare a string content each n seconds adter a new content have been downloaded?
<p>I have this code :</p> <pre><code>private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { BackgroundWorker worker = sender as BackgroundWorker; while (true) { if ((worker.CancellationPending == true)) { e.Cancel = true; break; } else { string content = downloadContent(); if (InvokeRequired) { BeginInvoke(new Action(() =&gt; textBox1.Text = content), null); } GetProfileNames(content); GetTextFromProfile(content); reader.Close(); response.Close(); Thread.Sleep(30000); } } } </code></pre> <p>And the downloadContent function:</p> <pre><code>private string downloadContent() { WebRequest request = WebRequest.Create(testingUrl); request.Method = "GET"; response = request.GetResponse(); Stream stream = response.GetResponseStream(); reader = new StreamReader(stream); string content = reader.ReadToEnd(); return content; } </code></pre> <p>I need that every 30 seconds it will download a new content like it does now, store the old content one before and compare the new download with the one before downloaded content.</p> <p>If they are identical dont do anything if they are not identical do something.</p>
c#
[0]
2,363,606
2,363,607
Can someone provide the URL for obtaining a Provisioning Profile?
<p>I downloaded a new SDK version and now I get this error.</p> <p>Code Sign error: The identity 'iPhone Developer' doesn't match any valid certificate/private key pair in the default keychain</p> <p>I don't need to deploy to the device just get my project running in XCode.</p> <p>Thanks in advance. jpc</p>
iphone
[8]
3,613,293
3,613,294
php while selecting a node should be highlighted
<p>I need to highlight the node value when I select it.how can I wrirte code for that in php my code is</p> <pre><code>function generate_menu($parent) { $has_childs = false; global $menu_array; foreach($menu_array as $key =&gt; $value) { if ($value['parentid'] == $parent) { if ($has_childs === false) { $has_childs = true; $menu .= '&lt;ul&gt;'; } $clor = 'black'; if(($_GET['id']&gt;0) &amp;&amp;($key == $_GET['id'])) { $clor = '#990000'; } $chld = generate_menu($key); $cls = ($chld != '')? 'folder' : 'file'; $menu .= '&lt;li&gt;&lt;span class="'.$cls.'" color='.$clor.'&gt;&amp;nbsp;' . $value['humanid'].'-'.$value['title'] . ' &lt;a href="index.php?id='.$key.'"&gt;&lt;img src="images/edit.png" alt=" Edit" title="Edit"/&gt;&lt;/a&gt;&lt;/span&gt;'; $menu .= $chld; $menu .= '&lt;/li&gt;'; } } if ($has_childs === true) $menu .= '&lt;/ul&gt;'; return $menu ; } </code></pre>
php
[2]
2,392,211
2,392,212
Can't access the method of an object inside a map
<pre><code>public void showTablet () { for (Map.Entry&lt;String, Tablet&gt; entry : tableMap.entrySet()) { //System.out.println(entry.getValue()); System.out.println(entry.getPrice()); } } </code></pre> <p>there is a getPrice method in a Tablet, but i can't get it? what's the problem?</p>
java
[1]
2,595,296
2,595,297
UINavigationController issue. viewWillDisappear/viewDidDisappear of view controllers not call on application startup
<p>I am writing an application(for iPhone) that uses the UINavigationController to show different view via <em>pushViewController</em>. I am trying to push multiple UIViewController immediately upon application startup without user interaction. When an user open up the application, they will be looking on a screen with a navigation bar on the top that already have a back button.</p> <p>The problem I am experiencing is that viewWillDisappear and viewDidDisappear of a ViewController does not always get call if another ViewController is pushed on top of it immediately upon application start up without user interaction. If the ViewController being pushed on top is activate by the user with a button click, then viewWillDisappear and viewDidDisappear of the view being cover always get call.</p> <p>Note. viewWillAppear and viewDidAppear of the covered view controller always get called.</p> <p>In the code that is experiencing the problem, I am pushing the new view controller in viewDidAppear of the previous ViewController.</p> <p>Anyone know what I might be doing wrong or if the behavior I am seeing is expected?</p>
iphone
[8]
3,632,304
3,632,305
Python: Finding a "=" in a string
<p>Using the python find function, I want to determine whether a string has an "=" sign in it. It could find anything else other a "=". </p> <p><code>string: Math="Fun".</code></p> <p><code>if (string.find("=") &gt; -1):</code></p> <p>Any ideas?</p>
python
[7]
193,035
193,036
Sharepoint webservices using Javascript
<p>I use a jquery dialog box to ask the user a daily question. I have a question and answer list which contains the information to load into the dialog box. I do not want the user to view or edit information in the question and answer list. However i do want to update the answer list based on the selected answer on the popup dialog box that is displayed to the user.</p> <p>I am using Javascript to update a list using sharepoint webservice. For the users who do not have permissions to view or edit the list is it possible to elevate their permissions to be able to update the answer list based on their selection from the popup dialog box. Is there a way to change the Soap Header to accomplish this ?</p>
javascript
[3]
412,824
412,825
Right to left layout in android
<p>I come from a web application development background and i am new to android, I am trying to create an application which has a right to left layout (Arabic) but I am facing a lot of problems with the alignment and text alignment, I understand that many people complain about android's support for rtl languages but I can see that there are many rtl applications in the android market which work just fine. Is there a simple clear way to handle rtl layout or do I have to do workarounds to reach a desired layout? Note: I am trying to develop using android 2.3 and 3.0 SDK</p> <p>Thanks</p>
android
[4]
704,940
704,941
Local variable not initialized catch-22
<p>Java newbie here! I need to create a Java method that keeps a running total of the values passed to it. However, if I use a local variable and keep initializing it, I will lose my running balance. Is there a way around this?</p>
java
[1]
5,008,703
5,008,704
How to get text from selected line in ListBox (c#)?
<p>I want to get data from selected line in List Box. I use command:</p> <pre><code>string selected = ListBox1.SelectedItems[0].ToString(); </code></pre> <p>But the result is:</p> <pre><code>ListVievItem: {here is correct value} </code></pre> <p>What should i do with this: "ListVievItem: {}"</p>
c#
[0]
4,986,464
4,986,465
Counter-intuitive behavior with virtual functions
<p>Given</p> <pre><code>#include &lt;string&gt; #include &lt;iostream&gt; struct A { virtual operator std::string() const { return "A"; } virtual operator const char *() const { return this-&gt;operator std::string().c_str(); } }; struct B1 : public A { virtual operator std::string() const { return "&lt;"; } }; struct B2 { B2() { } virtual ~B2() { } virtual operator std::string() const { return "&gt;"; } virtual operator const char *() const { return this-&gt;operator std::string().c_str(); } }; struct C1 : public A { C1() { } virtual ~C1() { } virtual operator std::string() const { return "["; } }; struct C2 { C2() { } virtual ~C2() { } virtual operator std::string() const { return "]"; } virtual operator const char *() const { return this-&gt;operator std::string().c_str(); } }; int main() { using namespace std; cout &lt;&lt; B1() &lt;&lt; endl; cout &lt;&lt; C1(); cout &lt;&lt; C2() &lt;&lt; B2() &lt;&lt; endl; } </code></pre> <p>The output should be "&lt;[]>". However, it is "&lt;[]]".</p> <ol> <li>Am I wrong? If so, why?</li> <li>If not, then what are the potential reasons for this behavior?</li> </ol>
c++
[6]
5,503,238
5,503,239
Setting browser homepage through JavaScript
<p>Is there any way to forcibly set a page as a homepage on the user's browser without any user notification or confirmation?</p>
javascript
[3]
5,580,477
5,580,478
Is there a simple way to remove a notification when it is clicked?
<p>My service pops up a notification when localization services are not enabled them. When the user clicks he's redirected to the system prefs (from which I can't call cancel() from the notification manager).</p> <p>Is there a simple way to remove a notification as soon as it is clicked?</p>
android
[4]
4,451,472
4,451,473
how to delete all contacts from android mobile by name
<p>How to delete all contacts number by name from android device. if number is stored in SDCard and what ever location, how to delete using programmatly? </p>
android
[4]
2,345,311
2,345,312
Common Practice when popup a alert dialog in my activity
<p>In my activity, I have an instance variable of AlertDialog aDialog; under some condition, my activity will pop up a dialog. </p> <p>My question is if I create aDialog, do I need to dismiss() in my onDestory() or onPause() of my activity?</p>
android
[4]
3,736,612
3,736,613
How do I identify or know which control is being referenced in a method?
<p>In my specific case, how do I identify or know which UITextField is being referenced in shouldChangeCharactersInRange method?</p> <p>I know the parameter (UITextField*)textField contains the object being referenced, but how do I compare to identify which one it is?</p>
iphone
[8]
3,721,897
3,721,898
How to input this method for calculating cost
<p>I am writing a class for a program where now I need to add a method for coming up with a late fee cost. This is between movie genre's with each genre costing something different but for the one I will use here will be the Drama genre which has the default late fee (That variable is in a different class, also the dayLate variable is in another class as well)</p> <p>Anyway what I need to do is make it so that the method adds it up like the number of days late multiplied by the fee. Right now I have this but I get a compiler error (Also if it matters, the class with the dayLate variable is not yet finished or compiled)</p> <p>Anyway here is the Drama class source code</p> <pre><code>class Drama extends Movie { public Drama() { super(); } public Drama(String rating, int IDnumber, String MovieTitle) { super(rating, IDnumber, MovieTitle); } public double CalcLateFees(Fee * dayLate); } </code></pre> <p>I don't think I did this method correct though.</p>
java
[1]
5,537,039
5,537,040
Program a Android emulator
<p>Does anyone know the start process of android emulator?I can find that a system.img file in my folder,and I often use emulator command to start a real emulator.Dose anyone know how the emulator command to load the system.img and how the emulator is manufactured? Actually,I want to know how to program a emulator to load the android system.img by myself. Thanks a lot.</p>
android
[4]
5,755,607
5,755,608
What are the scenarios in which case a new class will be loaded?
<p>That is when you have any jar file attached to you your class path. then as far as i know any class from the jar is loaded for the first time when,</p> <ol> <li>when you create any object of that type. or </li> <li>If you are accessing any static member or method of that class. or</li> <li>when you load that by using Class.forName() method.</li> </ol> <p>So are there any other ways of loading a class for the first time?</p>
java
[1]
4,213,088
4,213,089
save filename and headertext value as key value pair collection
<p>given the following text file:</p> <pre><code>Find all "HeaderText="", Subfolders, Find Results 1, "Entire Solution" C:\Documents and Settings\user\My Documents\Visual Studio 2008\Projects\WebApplication1\WebApplication1\Default.aspx(16): &lt;asp:BoundField DataField="CustomerID" HeaderText="CustomerID" ReadOnly="True" C:\Documents and Settings\user\My Documents\Visual Studio 2008\Projects\WebApplication1\WebApplication1\Default.aspx(18): &lt;asp:BoundField DataField="CompanyName" HeaderText="CompanyName" C:\Documents and Settings\user\My Documents\Visual Studio 2008\Projects\WebApplication1\WebApplication1\Default.aspx(20): &lt;asp:BoundField DataField="ContactName" HeaderText="ContactName" Matching lines: 3 Matching files: 1 Total files searched: 5 </code></pre> <p>what's the best way to put just the filename and the value of HeaderText in a collection?</p> <pre><code>for example, var test = new List&lt;KeyValuePair&lt;string,string&gt;&gt;(); test.Add(Default.aspx, CustomerID); test.Add(Default.aspx, CompanyName); test.Add(Default.aspx, ContactName); </code></pre>
c#
[0]
1,813,518
1,813,519
How can I convert a string with dot and comma into a float number in Python
<p>How can I convert a string like "123,456.908" to float number 123456.908 in Python? Thanks a lot.</p>
python
[7]
427,988
427,989
.append jquery, limit to one character per <span>
<p>I have these two functions:</p> <pre><code>jQuery.fn.enterText = function(e){ if( $("#cursor").val() &amp;&amp; e.keyCode != 32 ){ var character = $("#cursor").val(); $("#cursor").val(""); this.append("&lt;span class = 'text'&gt;"+character+"&lt;/span&gt;"); $("#cursor").insertAfter(".text:last"); $("#cursor").focus(); } }; jQuery.fn.markCursor = function(e){ $(this).focus(); $(this).keyup(function(e) { $("#cursor-start").enterText(e); }); }; </code></pre> <p>What my problem is that if I text is entered rapidly, some elements will have more than one character, for example (abc). I wanted to know how to limit to one character in an efficient manner, I thought of using an array, but would that not be too efficient?</p>
jquery
[5]
1,032,528
1,032,529
What is this called in Android (see picture)?
<p>I would like to know how the green plus sign in the following picture is called:</p> <p><img src="http://www.abload.de/img/how-to-change-contact-skj6.png" alt="picture"></p> <p>Thanks in advance for your help!</p>
android
[4]
4,332,752
4,332,753
Combining 2 variables in to 1 to call an ID
<p>I am trying to create the following code in a function that will repeat it a variable number of times</p> <pre><code>myId##.className = myId##.className.replace(' class1',' class2') </code></pre> <p>so far I have come up with the following but it is not working.</p> <pre><code>function toggle(partId,orig,rep,itr) { var partId; // Begining of Id string var orig; // Original Class var rep; // Replacement Class var itr; // Total number to be iterated through var num = 1; // Starting at 1 var finalId; // for partId + num while (num&lt;=itr) { finalId = partId + num; finalId.className = finalId.className.replace(orig,rep); num++; } } </code></pre> <p>I then implemented it like so.</p> <pre><code>&lt;area shape="circle" coords="933,92,23" alt="myAlt" href="#none" onmouseover="toggle('myPartId',' class1',' class2',5)" onmouseout="toggle('myPartId',' class1',' class2',5)" /&gt; </code></pre> <p>So I thought I could supplement the ID node in <code>className</code> and I am ether doing it wrong or I am wrong in that it can not be done.</p> <p>Any help would be greatly appreciated.</p>
javascript
[3]
5,224,450
5,224,451
problem binding to filtered dataview
<p>I'm having a problem with the dtaview. I'm dynamically creating new datacolumns, assigning them values, and adding them into my datatable. Before using a filter, this was fine when binding. All values appeared. </p> <p>However, I have since chosen to reduce returned results by filtering (by letter), and my returned dataview doesn't seem to allow binding with the newly created data columns. I've mined into the filtered view, and can see that the values are present that I need. </p> <p>I'm trying to avoid putting everything back into a table again after applying the filter. An sql query based on letter is out of the question, as the whole original table is sitting in view state.</p> <p>Here are some code snippets:</p> <pre><code> --Firstly create new datacolumn Dim ICount As System.Data.DataColumn = New System.Data.DataColumn ICount.DataType = System.Type.GetType("System.String") ICount.AllowDBNull = True ICount.ColumnName = "ICount" register.Columns.Add(ICount) --integer value is first calculated and then put into the datatable row row("ICount") = IntegerCount.ToString() --filtered view is created from datatable (returned from viewstate) Dim filteredView As New Data.DataView(pTable, FilterExpression, "Surname", Data.DataViewRowState.OriginalRows) --view is bound grd.DataSource = filteredView grd.DataBind() --Markup &lt;asp:TemplateField HeaderText ="ICount" SortExpression="ICount"&gt; &lt;ItemTemplate&gt; &lt;asp:Label ID="IC" runat="server" Text='&lt;%# Bind("ICount") %&gt;'&gt;&lt;/asp:Label&gt; &lt;/ItemTemplate&gt; &lt;/asp:TemplateField&gt; </code></pre> <p>All of the non dynamic datacolumns are fine. Mining into both the datatable and the filtered view show values are there.</p> <p>Any help would be much appreciated!!!</p>
asp.net
[9]
2,034,094
2,034,095
Android Tablet Serial Number (not IMEI/DEVICE_ID/SERIAL)
<p>i'm newbie</p> <p>I'm using samsung tab P3100 (ICS 4.04).on menus setting->about device->status, i can got the serial number of device.How to get this serial number value programmatically ?</p> <p>please help me...</p> <p>android.os.Build.Serial &lt;> Serial Number</p> <p>Note : Serial number &lt;> IMEI &lt;> android_id &lt;> mac address</p>
android
[4]
2,532,603
2,532,604
Given a List<int> how to create a comma separated string?
<p>Given a List&lt;int&gt; how to create a comma separated string?</p>
c#
[0]
4,053,339
4,053,340
'Querying' a data structure in Python based on a datetime
<p>I need a data structure which can handle the following:</p> <pre><code>date_from (datetime) date_to (datetime) value (float) </code></pre> <p>...and I need to be able to 'query' this data structure based on a datetime (e.g. in pseudocode: <code>SELECT * FROM data_structure WHERE a_datetime &gt;= date_from AND a_datetime &lt;= date_to;</code>).</p> <p>If there isn't a result from this 'query', I would need to be able to insert a new value into the data structure.</p> <p>What's the best way of doing this? (I'm a bit stuck at the moment)</p>
python
[7]
115,109
115,110
How can I filtering message using split method?
<p>I have a problem with filtering message.</p> <p>I want to make coordinates of GPS with Latitude and Longitude and I use GPS device with it (not in Android GPS device).</p> <p>I use message to send Latitude and Longitude coordinates.</p> <p>I use StringTokenizer to split a message with "-6.321123,106.321123" form. So I will get -6.321123 as Latitude and 106.321123 as Longitude. The problem is, if I get some message but not with that form, how can I filtering it? I use if condition but it still doesn't work.</p>
android
[4]
4,010,487
4,010,488
what's the difference between canonicalpath and absolutepath?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/1099300/whats-the-difference-between-getpath-getabsolutepath-and-getcanonicalpath">What&#39;s the difference between getPath(), getAbsolutePath(), and getCanonicalPath() in Java?</a> </p> </blockquote> <p>Any difference between those two?</p> <p>canonicalpath and absolutepath? </p> <p>If having difference, a real world example will be needed.</p>
java
[1]
5,547,890
5,547,891
Create a drawable from a created imageview
<p>I'm trying to create a drawable from an ImageView I know that we can do that with getressources : </p> <pre><code>Drawable drawable = getResources().getDrawable(imageview.getId()); </code></pre> <p>But my imageview is created programmatically, I can not get the ID even with the getID() method.</p>
android
[4]
1,046,518
1,046,519
open file with a running process
<p>I am making an application that can open a custom document. I connected the document extension to the application (using registry), but when I open the document, it is always opened with a new instance of the application.</p> <p>I want some logic that can open a document running the current process if it exists. I dont mean a single instance. It should be able to run by multiple instances. Like IE or chrome, it should be able to open an HTML file with tab when the process is running, but it can also run a new instance.</p> <p>How can I do it?</p>
c#
[0]
2,468,702
2,468,703
Android: safe/smart way to retrieve list of trusted CA?
<p>I am using the below code to retrieve this list. It seems to work, however it doesn't seem particularly safe/smart because I can't find any documentation that indicates the .bks file will always be available at the hard coded location. </p> <p>Is this method reasonable, or is there a safer/smarter way to go about this?</p> <pre><code>String filename = "/system/etc/security/cacerts.bks"; FileInputStream is = new FileInputStream(filename); KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType()); String password = "changeit"; keystore.load(is, password.toCharArray()); PKIXParameters params = new PKIXParameters(keystore); Iterator it = params.getTrustAnchors().iterator(); //iterate and such </code></pre>
android
[4]
32,241
32,242
Indoor positioning system in android
<p>I would like to ask a question regarding redpin indoor positioning system on android. I read somewhere stackoverflow about redpin and visited their website. From there i followed their instructions on how to set up redpin on android, but i only get a red dot pointing on the top left corner of the map i uploaded. I would like to know if anyone has successfully gotten redpin to work for android and assist me in doing so?....or maybe can tell me what am I doing wrong. Sorry to ask, I am very new at this, thank you.</p>
android
[4]
5,114,009
5,114,010
Calculate Angle of 2 points
<p>Given P1 and P2, how can I get the angle from P1 to P2? Thanks</p>
c++
[6]
4,856,178
4,856,179
JMegaHal library not displaying output correctly
<p>I've been working with a java implementation of MegaHal, which is an AI that generates statements in response to user input. (<a href="http://www.jibble.org/jmegahal/" rel="nofollow">http://www.jibble.org/jmegahal/</a>).</p> <p>The thing is, when I try to get a sentence from an instance of the class, using the built it function getSentence();, every time I print the output, I get a blank space. The function implementation is:</p> <pre><code>public String getSentence() { return getSentence(null); } </code></pre> <p>What I'm trying to do is:</p> <pre><code>System.out.println("hello world!"); JMegaHal test = new JMegaHal(); test.add("hi"); String S = test.getSentence(); System.out.println(S); </code></pre> <p>This outputs a blank line instead of the string. My java is a bit rusty, but I can't find anything wrong with the code... </p>
java
[1]
1,580,157
1,580,158
Accessing <declare-styleable> resources programatically
<p>I've one question where I couldn't find any help:</p> <p>Is it possible, to receive the resource-ids being kept by a as an int[] programatically without refering to the resource-class R ?</p> <pre><code>&lt;declare-styleable name="com_facebook_login_view"&gt; &lt;attr name="confirm_logout" format="boolean"/&gt; &lt;attr name="fetch_user_info" format="boolean"/&gt; &lt;attr name="login_text" format="string"/&gt; &lt;attr name="logout_text" format="string"/&gt; &lt;/declare-styleable&gt; </code></pre> <p>The problem is that I cannot resolve the ID of the defined 'declare-styleable' attribute - 0x00 is always returned:</p> <pre><code>int id = context.getResources().getIdentifier( "com_facebook_login_view", "declare-styleable", context.getPackageName() ); int[] resourceIDs = context.getResources().getIntArray( id ); </code></pre> <p>Any idea would be greatly appreciated! :)</p> <p>Thanks in advance!</p> <p>Christopher</p>
android
[4]
4,082,006
4,082,007
Is there an easier way to understand negation of a function result?
<p>I recently had to write a piece of code where I used the following; but it was very confusing for me and took me longer than I should</p> <p>I keep getting lost by the negation and false turning into true and then back maybe. I end up solving these problems by trial and error.</p> <p>Here is the code for getting rid of empty elements. NB, perhaps there are better code but I'm interested in knowing how to think this through</p> <pre><code>array_filter($array, "eliminate"); function eliminate($v) { return !(empty($v)); } </code></pre>
php
[2]
1,771,175
1,771,176
creating png files
<p>I made a function to handle jpg and png files, but i get error when trying to upload a png file.</p> <p>this is the function:</p> <pre><code>function createImg ($type, $src, $dst, $width, $height, $quality) { $newImage = imagecreatetruecolor($width,$height); if ($type == "jpg/jpeg") { //imagecreatefromjpeg() returns an image identifier representing the image obtained from the given filename. $source = imagecreatefromjpeg($src); } else if ($type == "png") { //imagecreatefrompng() returns an image identifier representing the image obtained from the given filename. $source = imagecreatefrompng($src); } imagecopyresampled($newImage,$source,0,0,0,0,$width,$height,getWidth($src),getHeight($src)); if ($type == "jpg/jpeg") { //imagejpeg() creates a JPEG file from the given image. imagejpeg($newImage,$dst,$quality); } else if ($type == "png") { //imagepng() creates a PNG file from the given image. imagepng($newImage,$dst,$quality); } return $dst; </code></pre> <p>}</p> <p>works as it should with jpg, but with png i get this error msg:</p> <p>Warning: imagepng() [function.imagepng]: gd-png: fatal libpng error: zlib failed to initialize compressor -- stream error in E:...\php\functions.upload.php on line 48</p> <p>Warning: imagepng() [function.imagepng]: gd-png error: setjmp returns error condition in E:...\php\functions.upload.php on line 48</p> <p>EDIT : </p> <p>i just changed removed the imagepng(); and used only imagejpeg and it worked like this, i just want jpg files saved anyways. thanks!</p>
php
[2]
1,566,337
1,566,338
Is it possible to detect what operating system a user is coming from using PHP? (mac or windows)
<p>Let's say for example I wanted to echo "You are using Windows!" or "You are using Macintosh!", depending on the users OS. Is this possible?</p>
php
[2]
3,660,636
3,660,637
What is default mode for cookieless in web config in ASP.NET?
<p>What is default mode for cookieless in web config in ASP.NET</p>
asp.net
[9]
3,415,647
3,415,648
Getting the time interval between typing characters in a TextBox, in C#
<p>I have a form that has a TextBox and a Label and I want to get the time of the first character entered in the textbox. Then if the user enters more than ten charcaters, the time between the first charcter entered and the tenth charcter entered is displayed in the label.</p> <p>Can any one help me please? I'm using C# </p> <p>Here is the code but I cannot complete it and I have many things that need to be written but I don't know how to continue.</p> <pre><code>using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Threading; namespace n { public partial class Form1 : Form { int count=0; public Form1() { InitializeComponent(); } private void textBox1_TextChanged(object sender, EventArgs e) { DateTime t1 = new DateTime();// the time when entering the first charcter DateTime t2 = new DateTime(); t2 = System.DateTime.Now - t1; int index = textBox1.SelectionStart; Point p; p = textBox1.GetPositionFromCharIndex(index); Thread t = new Thread(counttext); t.Start(); label1.Text = "t2"; } private int counttext() { while (textBox1.Text.Length &lt; 10) { count++; if (count == 10) return count; } } } } </code></pre>
c#
[0]
695,181
695,182
To fix my android application runs for all different sized screen android phones
<p>I tried to run my application on different sized screen android phones but the phones having small screens are not managing my layouts . how to adjust this ? </p>
android
[4]
2,014,121
2,014,122
Loading Javascript Dynamically and how to check if the script exists
<p>I am using the following technique to load up Javascript dynamically:</p> <pre><code>var script = document.createElement("script"); script.type = "text/javascript"; script.src = "file.js"; document.body.appendChild(script); </code></pre> <p>It's quite a common approach. It's also discussed here: <a href="http://www.nczonline.net/blog/2009/06/23/loading-javascript-without-blocking/" rel="nofollow">http://www.nczonline.net/blog/2009/06/23/loading-javascript-without-blocking/</a></p> <p>I know how to get notified once the file has been loaded and executed</p> <p>What I don't know is that if the link to the Javascript source file is broken how can I be notified. </p> <p>Thanks</p>
javascript
[3]
2,148,276
2,148,277
How to convert List<Article> to List<IArticle> in C# 3.5
<p>Code ex:</p> <pre><code>public Interface IArticle { int cid{get;set;} string Name{get;set;} string Content{get;set;} ... } public Class Article:IArticle { public int cid{get;set;} public string Name{get;set;} public string Content{get;set;} public string Extension{get;set;} ... } /* ArticleBiz.GetArticles(int cid) is select some items from database,return type:List&lt;Article&gt; */ List&lt;IArticle&gt; articleList=ArticleBiz.GetArticles(2).FindAll(p=&gt;p.cid==cid) </code></pre> <p>Exception:</p> <pre><code>Error 1 Cannot implicitly convert type 'System.Collections.Generic.List&lt;Zm.Models.Article&gt;' to 'System.Collections.Generic.IList&lt;Zm.Models.IArticle&gt;'. An explicit conversion exists (are you missing a cast?) </code></pre> <p>Question: I don't want to change the return type to <code>List&lt;IArticle&gt;</code> in the <code>GetArticles(..)</code> method. How can I change the code to convert <code>List&lt;Article&gt;</code> to <code>List&lt;IArticle&gt;</code> successfully?</p>
c#
[0]