Unnamed: 0
int64
65
6.03M
Id
int64
66
6.03M
Title
stringlengths
10
191
input
stringlengths
23
4.18k
output
stringclasses
10 values
Tag_Number
stringclasses
10 values
1,148,833
1,148,834
Using $_POST information only once
<p>I have some information which gets passed from a form and needs to be used once and only once. I can collect it nicely from $_POST but I'm not sure which is the "best" way to ensure that I can only use it once, i.e. I want to avoid the user pressing F5 repeatedly and accessing the function more than once. </p> <p>My initial thought was to set a session variable and time the function out for a set period of time. The problem with that is thay could have access to the function again after the set period has elapsed.</p> <p>Better ideas welcomed!</p>
php
[2]
4,354,512
4,354,513
How to log method calls on targets marked with an attribute?
<p>Is it possible to inject Loggin behaviour to the marked classes or/and methods like this:</p> <pre><code>Log("Method {0} started",GetMethodNameTroughReflection) Call method body Log("Method {0} Finished",GetMethodNameTroughReflection) </code></pre> <p>I want to create my own Attribute class, which will realize loging behaviour for method call.</p> <p>I want to describe login behaviour in the app.config file, thoug it can be disabled by a setting in config.</p> <p>How to do it right? Maybe there is created solution for tasks like this one?</p>
c#
[0]
5,306,528
5,306,529
Foreach to change a key
<p>I retrieve a set of mysql row as an array of associative arrays (I'm using pdo fetch all). My associative arrays holds a key named "password". How do I loop throught the arrays to change all the password values? I need to set them to 0 if the password is equal to 0, 1 instead.</p> <pre><code>$result = $stmt-&gt;fetchAll(PDO::FETCH_ASSOC); /* gotta strip all the password, I can't send them! */ foreach($result as $res) $res['password'] = (!$res['password']) ? 0 : 1; </code></pre>
php
[2]
5,076,863
5,076,864
python: how to generate pairs of cards in a deck
<p>Suppose that I have the following variables:</p> <pre><code>suits = ["h","c", "d", "s"] cards = ["2","3", "4", "5", "6", "7", "8", "9", "t", "j", "q", "k", "a"] deck = [] for suit in suits: for card in cards: deck.append(str(card+suit)) </code></pre> <p>I'd like to write a function that, given a specific card, generates the possible combinations of pairs.</p> <p>For instance, <code>generatePairs('a')</code> should return something like:</p> <p><code>['ahac','ahad','ahas','acad','acas','adas']</code></p> <p>but I'm not sure how to approach writing that function.</p>
python
[7]
3,793,581
3,793,582
How to reference widget inside of a Service?
<p>How to i i set the TextView and ProgressBar to their findViewById views from inside a service?></p> <pre><code> ProgressBar dialog; TextView Titletext; @Override public IBinder onBind(Intent intent) { // TODO Auto-generated method stub return null; } @Override public void onCreate(){ super.onCreate(); Log.e("StackWidgetService", "Inside of onCreate in Widget Service"); getter fethcer = new getter(); fethcer.execute(); } </code></pre>
android
[4]
3,863,226
3,863,227
Strange issue using sem_t + pthread_create
<p>Strange behaviour when passing argument sem_t to constructor A. Expected output was <code>5555</code> but i got <code>5055</code>. Please point out if there are design problems too.</p> <pre><code> 1 #include &lt;iostream&gt; 2 #include &lt;pthread.h&gt; 3 #include &lt;semaphore.h&gt; 4 using namespace std; 5 6 class A { 7 public: 8 pthread_t thr_id; 9 int&amp; k; 10 11 A(sem_t&amp; sem, int k) : k(k){} 12 A(int k) : k(k){} 13 14 void start(){ 15 cout &lt;&lt; k; 16 pthread_create(&amp;thr_id, NULL, foo2, NULL); 17 cout &lt;&lt; k; 18 } 19 void join(){ 20 pthread_join(thr_id, NULL); 21 } 22 static void* foo2(void* i){} 23 }; 24 25 int main() { 26 sem_t sem; 27 A* ac1 = new A(sem, 5); 28 ac1-&gt;start(); 29 ac1-&gt;join(); 30 A* ac2 = new A(5); 31 ac2-&gt;start(); 32 ac2-&gt;join(); 33 return 0; 34 } </code></pre>
c++
[6]
5,334,174
5,334,175
Hello please let me about learning iphone(i need best book for beginers)
<p>Hi I am new to Objective C and iphone developments, please specify me a way to learn about iphone developments please help...</p> <p>Regards</p> <p>GuruPrasad R Gujjar.</p>
iphone
[8]
3,216,800
3,216,801
Sending Periodically Email From Asp.Net
<p>I want to send an email to the admin from my asp.net web application daily at 8:00 am. How to send an email that I know. But how to send it periodically that I doubt. Not through SQL Server. I have written my logic in Application_Start in Global.asax Is this is right? Please guide me as soon as poosible as it is urgent.</p> <p>Thanks in advance. Any help would be appreciated.</p> <p>Regards</p> <p>Asif</p>
asp.net
[9]
5,395,323
5,395,324
Custom Notification
<p>I would like to know if there is a way of using the notication bar in order to do some operations (onClick), without having an activity being launched/resumed.</p> <p>for example.. let's say i raise a notifcation, and when the user press on it, then instead of take me to some activity, it invoke some regular method in my current activity/service</p> <p>Is there any way to implement such a thing?</p> <p>for example the current notifcation code do a standart behave onClick. running up an activity.. how will channge the code in order to invoke some method instead of an activity?</p> <pre><code> messagesManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); Notification notification = new Notification(R.drawable.icon, message, System.currentTimeMillis()); PendingIntent contentIntent = PendingIntent.getActivity(context, 0, new Intent(context, someActivity.class), 0); notification.setLatestEventInfo(context, "notification", message, contentIntent); messagesManager.notify(R.string.noto, notification); </code></pre>
android
[4]
5,312,115
5,312,116
Passing parameter from android to .net web service
<p>Im using ksoap2 to call web .net services. The call works just fine except when I pass paramaters. The passed paramaters are always recieved as null values by the web service. I dont know what the problem is, I hope someone can help. Thanks,</p> <p>My code is below please help me</p> <pre><code>package com.android.countrycode; import org.ksoap2.SoapEnvelope; import org.ksoap2.serialization.PropertyInfo; import org.ksoap2.serialization.SoapObject; import org.ksoap2.serialization.SoapSerializationEnvelope; import org.ksoap2.transport.HttpTransportSE; import android.app.Activity; import android.os.Bundle; import android.util.Log; import android.widget.TextView; public class CountryActivity extends Activity { /** Called when the activity is first created. */ private static final String SOAP_ACTION = "http://www.webserviceX.NET/GetCountryByCountryCode"; private static final String OPERATION_NAME = "GetCountryByCountryCode"; private static final String WSDL_TARGET_NAMESPACE = "http://www.webserviceX.NET/"; private static final String SOAP_ADDRESS = "http://www.webservicex.net/country.asmx"; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); TextView textView = new TextView(this); setContentView(textView); SoapObject request = new SoapObject(WSDL_TARGET_NAMESPACE,OPERATION_NAME); //PropertyInfo pi = new PropertyInfo(); //pi.setName("CountryCode"); //pi.setValue("AS"); //request.addProperty(pi); //request.addAttribute("CountryName", "Portugal"); //request.setProperty(1, "Portugal"); request.addProperty("CountryCode","AS"); SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); envelope.dotNet = true; envelope.setOutputSoapObject(request); HttpTransportSE httpTransport = new HttpTransportSE(SOAP_ADDRESS); try { httpTransport.call(SOAP_ACTION, envelope); Object response = envelope.getResponse(); textView.setText(response.toString()); System.out.println(response.toString()); } catch (Exception exception) { String exceptionStr=exception.toString(); textView.setText(exceptionStr); System.out.println(exceptionStr); Log.i("TAG",exceptionStr); } } } </code></pre>
android
[4]
727,102
727,103
Capturing the hot keys from a thread using c#;
<p>I am using the below code to capture the ctrl + alt + Q hot keys, which works perfectly. But, i want to use this in a background application. Since my application does not have any forms, i want to use the same code inside a class file.</p> <p>i am confuse, because i cannot write a event handler [keypressed] in class file. Instead i want to use the keypress in thread.</p> <p>Please help.</p> <pre><code> public DialogResult Result; KeyboardHook hook = new KeyboardHook(); public Form1() { InitializeComponent(); // register the event that is fired after the key press. hook.KeyPressed += new EventHandler&lt;KeyPressedEventArgs&gt;(hook_KeyPressed); // register the control + alt + F12 combination as hot key. hook.RegisterHotKey((ModifierKeys)2 | (ModifierKeys)1, Keys.Q); } void hook_KeyPressed(object sender, KeyPressedEventArgs e) { Result = MessageBox.Show("Are you sure, you want to log off?","Log off" ,MessageBoxButtons.YesNo ,MessageBoxIcon.Warning); if (Result == DialogResult.Yes) { } else { } } </code></pre>
c#
[0]
2,160,175
2,160,176
Session time out in PHP
<p>HI, i have code for session time out but i dont know whats the issue its not working someone pls look at this and help me. Here is the code:</p> <pre><code> $inactive = 10; // check to see if $_SESSION['timeout'] is set if(isset($_SESSION['timeout']) ) { $session_life = time() - $_SESSION['timeout']; if($session_life &gt; $inactive) { session_destroy(); header("Location: logoutpage.php"); } } $_SESSION['timeout'] = time(); </code></pre> <p>Thanks.</p>
php
[2]
1,256,052
1,256,053
Is it posible to get the current location in Android MapView without using Location Listener?
<p>I have a MapView application. When application launches it should show the current location. How to do this?</p>
android
[4]
3,786,080
3,786,081
Count the occurrence of any number of characters in a file?
<p>I have found several ways to count the occurrence of a single character in a file in Java. My question is simply this: is there any way to count the occurrence of any of the characters in a list in a file simultaneously, or am I going to have to loop through each character?</p> <p>To clarify, I'm wanting something equivalent to: For each character in file, if character in list "abcdefg" increment 1.</p> <p>Background: I'm counting predicates in a file, and the best method I could think of was to search for occurrences of &lt;, >, ==, etc.</p>
java
[1]
6,014,896
6,014,897
android how to know a protocol can be handled?
<p>One app in my system can handle URI like "weibo://abc", I want to start the intent using this URI. But in other machine before starting this URI I need to check if this URI can be handled correctly(without big delay), what I should do?</p>
android
[4]
1,696,682
1,696,683
Android- Running my application on 2.1 and higher versions
<p>I want to make application that support 2.1 or higher platforms. Does anyone have solution for it? Can I use somekind of cross-platform for it or cross-platefroms are only for porting applications from differnt OS? Or there is any library i can use for this purpose?</p>
android
[4]
1,862,877
1,862,878
How to distinguish between a SHA1 string and a date-time string?
<p>Basically I have two options:</p> <pre><code>$one = "fdfeb16f096983ada02db49d46a8154475d700ae"; $two = "2011-12-28 05:20:01"; </code></pre> <p>I need some sort of regex, so that I can detect wether the string follows the pattern in <code>$one</code>, or the pattern in <code>$two</code></p> <p>Detect if the string is sha1 or datetime.</p> <p>What would be the best way to determine this?</p> <p>Thanks</p>
php
[2]
2,380,317
2,380,318
How to add a hidden value to DataGridView TextBox? (C#)
<p>I am working with an existing GridView and I want to know if there is a way I can have a different value and display for the TextBoxColumn, similar to a ComboBoxColumn (displaymember, valuemember). </p> <pre><code>private System.Windows.Forms.DataGridViewTextBoxColumn PATH; this.PATH.DataPropertyName = "Path"; this.PATH.HeaderText = "PATH"; this.PATH.Name = "Path"; this.PATH.ReadOnly = true; this.PATH.Width = 186; </code></pre> <p>Right now I have a hidden column with the ID but I am wondering if there is a better solution.</p> <p>ETA: I have put PATH.DataPropertyName = "PathId" (the hidden value I want to use for update) and this.PATH.Name = "Path" (The string value I want displayed) </p> <p>The Name value is still returned when I get the value of the column. </p> <p>this.mySampleGridView.Rows[i].Cells["Path"].Value</p>
c#
[0]
3,118,024
3,118,025
Put LI with "active" class first in UL
<p>i have an unordered list like this:</p> <pre><code>&lt;ul&gt; &lt;li class="first"&gt;&lt;a href="/nl"&gt;&lt;span&gt;Nederlands&lt;/span&gt;&lt;/a&gt;&lt;/li&gt; &lt;li class="active"&gt;&lt;a href="/fr"&gt;&lt;span&gt;Français&lt;/span&gt;&lt;/a&gt;&lt;/li&gt; &lt;li class="last"&gt;&lt;a href="/de"&gt;&lt;span&gt;Deutch&lt;/span&gt;&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; </code></pre> <p>I need the LI which has the class "active" to be first in the list nomatter what its original position was. Anyone a suggestions on how to do this with jquery?</p>
jquery
[5]
1,686,173
1,686,174
Finding a / symbol in string
<p>I'm trying to find a forward slash in a string...</p> <p>This doesn't seem to work:</p> <pre><code>if ("/test".indexOf("/") &gt; -1) { </code></pre> <p>What am I doing wrong?</p> <p>Funny thing is... I tried this:</p> <pre><code>if ("!test".indexOf("!") &gt; -1) { </code></pre> <p>and it works! I also tried \/ for that... help?</p>
java
[1]
1,472,149
1,472,150
Consuming encapsulated member event
<p>I'm trying to comsume an encapsulated member event. Let me explain. I have MyClassA, which has a private member of MyClassB _obj:</p> <pre><code>public class MyClassA { private MyClassB _obj; public MyClassA() { _obj = new MyClassB(); } } </code></pre> <p>MyClassB has SaveProgress event. </p> <p>For the client application, MyClassB is invisible. We need to handle its event through MyClassA:</p> <pre><code>public partical class _Default: System.Web.UI.Page { protected void button1_Click(object sender, EventArgs e) { MyClassA objA = new MyClassA(); // We need to handle it's event through MyClassA // objA.SaveProgress += new EventHandler&lt;SaveProgressEventArgs&gt;(objA_SaveProgress); } } </code></pre> <p>How can I do that? Thanks.</p>
c#
[0]
488,134
488,135
How can i parse this array
<p>Lets say this was my retrieved object <code>$myObj</code></p> <pre><code>Array ( [0] =&gt; xl_oio_0_1_Mytitle Object ( [_unknown:protected] =&gt; [header_:protected] =&gt; Header Object ( [_unknown:protected] =&gt; [myId_:protected] =&gt; my_title [userId_:protected] =&gt; [createTime_:protected] =&gt; ) [id_:protected] =&gt; ID Object ( [_unknown:protected] =&gt; [id_:protected] =&gt; ingy3spdzE1uiMtCYRSlmwtX ) [dataType_:protected] =&gt; 2 [picSize_:protected] =&gt; 8669 [userId_:protected] =&gt; ID Object ( [_unknown:protected] =&gt; [id_:protected] =&gt; ingy3spdzE1uiMtCYRSlmwtX ) [fName_:protected] =&gt; Joe [lName_:protected] =&gt; Smith [cDate_:protected] =&gt; RxyascTe89Xe4 ) [1] =&gt; etc... </code></pre> <p>And I am trying to parse the name and date, ive tried the following with no luck.</p> <pre><code>$i=0; while( $i &lt; 20 ){ // Notice: Trying to get property of non-object //$firstName = $myObj-&gt;xl_oio_0_1_Mytitle-&gt;fName_; // Fatal error: Cannot use object of type //$firstName = $myObj[$i]['fName_']; // Parse error: syntax error, unexpected T_OBJECT_OPERATOR $firstName = $myObj-&gt;xl_oio_0_1_Mytitle(object-&gt;fName_); echo $firstName . '&lt;br /&gt;'; $i++; } </code></pre>
php
[2]
5,178,570
5,178,571
Program to tell what scripts are running in a browser?
<p>Is there a program that tells me the script that a browser executes for a particular event? for example, what script clicking on a button initiates? </p>
javascript
[3]
3,743,933
3,743,934
Dynamically Change TextView Background color in onclicklistener in android
<p>If we click any of the Textview within a Listview, background color should have to change and onclick release, it should have to change to transparent color in android.How to achieve this in onclicklistener of Textview in android.</p>
android
[4]
258,484
258,485
Animating a div while it fits to dynamically loaded content
<p>I have two Divs. 'contents' (outer) and 'info' (inner). 'info' will have dynamically loaded data from 4-5 external html files. 'contents' just contains just a black background. Now I have managed to load the html but i want smooth animation of the background ('contents') to wrap around the inner div according to content. My current code wraps it but I want the background transition to happen slowly. </p> <p><strong>HTML:</strong> </p> <pre><code>&lt;div id="menu-content"&gt; &lt;div id="info"&gt;&lt;/div&gt; &lt;/div&gt; </code></pre> <p><strong>CSS of the two divs:</strong></p> <pre><code>#contents { background:rgba(0,0,0,0.2); -moz-border-radius: 9px; -webkit-border-radius: 9px; margin:0px 25px 25px 25px; position:relative; opacity:0; color: #F4F4F4; float: left; } #info { position:relative; color: #F4F4F4; padding: 15px 25px; float:left; } </code></pre> <p><strong>.JS code:</strong></p> <pre><code>$('#info').css('opacity','0').load('company.html'); var width = $('#info').css("width") + 50; var height = $('#info').css("height") + 30; $('#contents').css('opacity','1').animate({ 'width': width, 'height': height }, 300, function(){ $('#info').animate({'opacity':'1'},500) }); </code></pre> <p>Am very new to jQuery so please go easy on me.. Thanks. </p>
jquery
[5]
2,808,046
2,808,047
Error: Could not find or load main class Hello2
<p>I'm just learning java and following a book.</p> <p>I have a program written via text editor and run commands via cmd.</p> <p>I've complied 1 program thru javac and executed thru java no problem. (Hello) Then I modified that to add a comment to the class, named file Hello2.java. I compiled it with no problems, but upon execution, I receive this error: Could not find or load main class Hello2.</p> <p>I have classpath and path set correct;y on environment variables.</p> <p>Ideas?</p> <p>UPDATE</p> <p>Hello.java</p> <pre><code> public class Hello { public static void main(String[] args) { System.out.println("Hello, world!"); } } </code></pre> <p>Hello2.java</p> <pre><code>//Filename Hello2.java //Written by //Written on public class Hello2 { public static void main(String[] args) { System.out.println("Hello, world!"); } } /*This class demonstrates the use of the println() method to print the message Hello, world! */ </code></pre>
java
[1]
4,987,098
4,987,099
difference between len() and .__len__()?
<p>Just curious,</p> <p>Is there any difference between calling <code>len([1,2,3])</code> or <code>[1,2,3].__len__()</code> ? If there is no apparent difference, what is done differently behind the scenes?</p> <p>Thanks</p>
python
[7]
131,897
131,898
constructor of the class containing another class as member variables
<p>I am try to make a class containing another class as member variable. And I encounter the follow problem:</p> <pre><code>class SubClass{ .... }; class MainClass{ public: MainClass(SubClass const &amp; subClass_); private: SubClass subClass }; </code></pre> <p>and in the .cpp files for the constructor</p> <pre><code>MainClass::MainClass(SubClass const &amp; subClass_){ subClass = subClass_; } </code></pre> <p>This gives out compiler errors. But the following works:</p> <pre><code>MainClass::MainClass(SubClass const &amp; subClass_): subClass(subClass_) {} </code></pre> <p>Could anyone tell me what is the difference of these two? </p> <p>Thanks!</p>
c++
[6]
180,502
180,503
Javascript - determining if value in array is positive, negative (use switch)
<p>Ok so I'm trying to write some code to determine whether or not values in a static array are positive, negative or equal to zero.</p> <p>So the array is populated and I'd use a switch statement to go through the values and output text depending on if it is above, below or equal to zero. </p> <p>Here's some of the code I've been doing so far with this. </p> <p>Please keep answers which pertain to the use of switches! Thanks in advance. </p> <p>Note: I'm teaching myself JS, so I'm new to this. Here's my code so far:</p> <pre><code>// JavaScript Document var numbers=new Array(); numbers[0]="1"; numbers[1]="2"; numbers[2]="3"; numbers[3]="-1"; numbers[4]="-2"; numbers[5]="-3"; numbers[6]="0"; switch (numbers) { case "positive": if (numbers&gt;0) {alert("DERP")}; break; case "negative": if (numbers&lt;0) {alert("NO DERP")}; break; case "zero": if (numbers==0) {alert("STILL DERP")}; break; } </code></pre>
javascript
[3]
219,992
219,993
IntentFilter not working when created runtime
<p>I have a problem. I need to interupt link that are not static but the user will create list of all at runtime. So I am creating my intentfilter object at runtime. So when i use the code in manifest file it works.But using it in java class doesn't work for me. Here's the code </p> <p>This is not working</p> <pre><code>IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_VIEW); filter.addCategory(Intent.CATEGORY_DEFAULT); filter.addCategory(Intent.CATEGORY_BROWSABLE); filter.addDataAuthority("www.facebook.com", null); filter.addDataScheme("http"); RecieveBroadcaster receiver = new RecieveBroadcaster(); registerReceiver(receiver, filter); </code></pre> <p>But if setting statically it works in manifest</p> <pre><code> &lt;intent-filter&gt; &lt;action android:name="android.intent.action.VIEW"/&gt; &lt;category android:name="android.intent.category.DEFAULT"/&gt; &lt;category android:name="android.intent.category.BROWSABLE"/&gt; &lt;data android:scheme="http" android:host="twitter.com"/&gt; &lt;data android:scheme="http" android:host="facebook.com"/&gt; &lt;/intent-filter&gt; </code></pre>
android
[4]
3,786,057
3,786,058
What's the right way to disconnect a MediaController?
<p>What's the right way to shut down a MediaController with an attached MediaPlayer?</p> <p>You can't do mediaController.setMediaPlayer(null) - that immediately calls updatePausePlay, which dereferences the null.</p> <p>You can't call mediaPlayer.release(), since MediaController is going to call MediaPlayer#getCurrentPosition, and that throws an IllegalStateException after release() has been called.</p>
android
[4]
4,042,592
4,042,593
C# Enumerable Range
<p>What is the way to get Range "A"..."Z" like</p> <pre><code>Enumerable.Range(1,100) Enumerable.Range("A","Z"); </code></pre>
c#
[0]
6,019,068
6,019,069
smallest format for videos in an iphone app
<p>I have a lot of videos I would like to embed into an app, and am currently just streaming them using an UIWebView browser I set up.</p> <p>I know there are formats available to email videos, where videos can be like 6 mb or less.</p> <p>What is the best way to do this for an iphone app.</p> <p>Keeping the quality of the picture to some extent with smaller file sizes.</p> <p>thanks</p>
iphone
[8]
4,094,489
4,094,490
I am not getting the 'Profile' property in the code behind
<p>I have added some profile properties to my web.config:</p> <pre><code>&lt;profile automaticSaveEnabled ="true"&gt; &lt;properties&gt; &lt;add name="NumVisits" type="System.Int32"/&gt; &lt;add name="UserName" type="System.String"/&gt; &lt;add name="Gender" type="bool"/&gt; &lt;add name="Birthday" type="System.DateTime"/&gt; &lt;/properties&gt; &lt;/profile&gt; </code></pre> <p>However when I try to access the property in a code behind it does not exist. The following code does not work (says firstname is not a property):</p> <p>Profile.Gender And In the Asp.net Configuration 'Profile tab ' Is not showing. I have rebuilt the solution. I am using VB.NET(3.5)</p>
asp.net
[9]
5,424,132
5,424,133
For items in a dictonary, split the name of one item, add and remove some info python
<p>I have a dictionary with this info: </p> <pre><code>x = {Country:{City:Population},.....} </code></pre> <p>but City name is now like: <code>Country_City_Neighbourhood_Population</code> (for some reason). I need to remove all the information and just keep the City and Neighbourhood like this: <code>CityNeighbourhood</code>.</p> <p>I did this:</p> <pre><code>for country in x: for city, pop in x[country].iteritems(): isCountry = city.split("_").count("Ecuador") if isCountry &gt; 0: city1 = city.split("_") city1.remove("Ecuador") city2 = city1[0:-1] city3 = "" for i in range(len(city2)-1): city3 = city3 + city2[i] </code></pre> <p>but I didn't obtain any reasonable result. </p>
python
[7]
4,177,614
4,177,615
not clear with stripslash() functionality
<p>I am new in PHP world. While going through couple of functions i came across stripslash() I am not clear about it's benefit. Gone through couple of google link but still it's benefit is not clear.</p> <pre><code>&lt;?php $array=array("a"=&gt;"0","b"=&gt;"1","c"=&gt;"2"); print_r ($array); print "\n"; foreach($array as $key=&gt;$value) { print "Before stripslash : $value\n"; stripslashes($value); print "After stripslash : $value\n"; } print_r ($array); ?&gt; </code></pre> <p>Output:</p> <p>Array ( [a] => 0 [b] => 1 [c] => 2 )</p> <p>Before stripslash : 0 After stripslash : 0 Before stripslash : 1 After stripslash : 1 Before stripslash : 2 After stripslash : 2</p> <p>Array ( [a] => 0 [b] => 1 [c] => 2 )</p>
php
[2]
5,177,200
5,177,201
Store huge amount of data in assembly
<p>I'm trying to make an assembly which I can use in mutliple programs. The assembly contains a huge amount of countries and a huge amount of towns in that country. the data for countries is not much of a problem because I only count 249 countries but I also have huge amount of data for towns.</p> <p>For example france has nearly 50.000 towns. Belgium has nearly 2500 towns. United kingdom nearly 150.000 towns. ...</p> <p>I already have all the data I need but my problem is. I have no idea how to store the data in my assembly. - I tried XML but loading the xml give me performance issues. It takes to long to load the data. - I tried a MS Access database but then the data is store in a database outside my assembly while I try to keep the data inside my assembly. which means thats not my solution to. - I tried loading the data directly in an array in my script but then my visual studio keep loading all day long checking the data I entered but I can't work with it anymore</p> <p>Anyone can give me a way to store data in my assembly without having these performance issues?</p> <p>Any help is welcome.</p> <p>I work with visual studio 2010 in the language C#</p>
c#
[0]
5,228,928
5,228,929
socket programming in windows to send data freezes for sometime and getting delayed for sometime?
<p>I am able to send data successfully with a static class through socket programming, it works fine for small amount of data but in production environment it is freezing for sometime and again it is starting to send data, i am unable to figure out what is the problem? can you please help. Code is as below.</p> <pre><code> DWORD BytesCount; WSABUF Buffer[1]; DWORD Flag = 0; Buffer[0].len = SendLength; Buffer[0].buf = SendData; if (WSASend(*socket, Buffer, 1, &amp;BytesCount, Flag, NULL, NULL) != SOCKET_ERROR) { if (BytesCount != SendLength ) Result = -2; else { if (ReturnAnswer) { int Res = 0, recBufStart; DWORD RecvCount = 0, AllRecv = 0; Buffer[0].len = ReceiveLength; Buffer[0].buf = ReceiveData; recBufStart = 0; saAction = saReceive; // We need to Receive until we get all the data. When WSARecv call might only return zero bytes bool Stop = true; // true as we dont need to recieve anything from the server. while (!Stop) { Res = WSARecv(*socket, &amp;Buffer[recBufStart], (recBufStart == 0 ? 1 : 0), &amp;RecvCount, &amp;Flag, NULL, NULL); if (Res == SOCKET_ERROR) Stop = true; else { AllRecv = AllRecv + RecvCount; if (AllRecv == ReceiveLength || RecvCount == 0) Stop = true; // Stop else { Buffer[0].buf = &amp;ReceiveData[AllRecv]; Buffer[0].len = ReceiveLength - (AllRecv); recBufStart = 0; } } } if (Res == SOCKET_ERROR) Result = WSAGetLastError(); } } } else Result = WSAGetLastError(); </code></pre>
c++
[6]
4,083,946
4,083,947
Send data from phone to phone over internet?
<p>Is there any way to actually communicate between two android devices over internet without having to have any service between the two devices? </p> <p>Like posting something to device2 from device1 without having to "middle-land" on any other server or whatever?</p> <p>Another question: I tried to ping my phone over the internet (simply using the IP address), which didn't work, since it seems like my ISP shares the same WAN-IP for all the phones or at least a few of them. So is there any way to actually ping or send data to my specific phone just by using the IP or my Google account or something?</p>
android
[4]
2,539,786
2,539,787
Exclude .cs from project through code? (Visual Studio)
<p>I need to exclude .cs files from project through code, for example with T4 template. I know that you can modify the .csproj file, but this doesn't work properly if the project is opened with Visual Studio, so is there any way to exclude/add .cs files through code(for example, with T4 templates)?</p> <p>Thanks</p>
c#
[0]
5,454,153
5,454,154
Select file to upload from source
<p>On a webpage the user can select a file to upload then if he submits the form he is directed to the next webpage with a similar, but bigger form. The form elements are filled with the data he entered on the last page</p> <p>firstpage.html</p> <pre><code>&lt;form name="MyForm" action="nextpage.php" enctype="multipart/form-data" method="post"&gt; &lt;input type="text" name="name" size="50"&gt; &lt;input type="file" name="file" id="file" size="40"&gt; &lt;/form&gt; </code></pre> <p>nextpage.php (partial form, two elements are the same)</p> <pre><code>&lt;form name="MyForm" action="thirdpage.php" enctype="multipart/form-data" method="post"&gt; &lt;input type="text" name="name" size="50" value="&lt;?php echo $name?&gt;"&gt; &lt;input type="file" name="file" id="file" size="40"&gt; &lt;/form&gt; </code></pre> <p>Is it possible to preselect a file in the file upload element? If he types his name in the name element on firstpage.html, the same element is filled with the name on nextpage.php. But if he selects a file on firstpage.html, is it possible that he doesn't need to select it again on nextpage.php?</p>
php
[2]
3,551,196
3,551,197
Why define constants in a class versus a namespace?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/4977330/static-members-class-vs-normal-c-like-interface">Static members class vs. normal c-like interface</a> </p> </blockquote> <p>I am looking at somebodies code and there are several dozen constants defined in a class like this:</p> <pre><code>// header file class Defines { public: static const int Val1; static const int ValN; static const char* String1; static const char* StringN; ... } // .CPP const char* Defines::String1 = "some value" etc. </code></pre> <p>Is there some reason to do things this was as opposed to using a namespace instead? Are there advantages/disadvantages of one over the other</p> <p>--------- Edit ----------</p> <p>I'm sorry, I obviously should have pointed this out explicitly, as nobody has inferred it from the name of the class - which is "Defines". i.e. these constants are not associated with a particular class, there has been a class created specifically just to hold constants and nothing else, that is all the class Defines contains. </p> <p>My question is not why should you place constants in a particular class, the question is is there any value in collecting dozens of them together and placing them <em>in a class</em> whose only purpose is to collect together constants, as opposed to collecting them together in a namespace, or just collecting them together in a header file specifically for that purpose etc. </p> <p>(There is no currently existing namespace in the project therefore potential issues of polluting the namespace as mentioned in answers are not relevant in this case.)</p> <p>----- 32nd edit -----------</p> <p>and a follow up question --- is placing const char* Defines::StringN = "Somevalue" </p> <p>in the .h file inefficient versus placing it in the .cpp file?</p>
c++
[6]
403,014
403,015
Disable a link that has href="javascript:;" until option is selected
<p>I have a link I need to disable until a selection is made from a select box</p> <pre><code>&lt;select id="shippingSelect" onchange="simpleCart.update();"&gt; &lt;option value="nothing" selected="selected"&gt;Choose Shipping Location&lt;/option&gt; &lt;option value="uk"&gt;UK - FREE&lt;/option&gt; &lt;option value="world"&gt;Rest of World + £2.00&lt;/option&gt; &lt;/select&gt; &lt;a href="javascript:;" class="simpleCart_checkout"&gt; Place Order &lt;/a&gt; </code></pre> <p>How can I disable the place order link until customer chooses shipping location?</p> <p>This is what I have at the moment:</p> <pre><code>&lt;script&gt; $('#shippingSelect').change(function() { if ($(this).val() != "nothing") { $('.place_order').slideDown(); } else { $('.place_order').slideUp(); } }); &lt;/script&gt; </code></pre> <p>Which works but I would rather have the link visible all the time just not clickable. Thanks</p>
jquery
[5]
1,969,356
1,969,357
Differece between Static and reinerpret cast
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/332030/when-should-static-cast-dynamic-cast-and-reinterpret-cast-be-used">When should static_cast, dynamic_cast and reinterpret_cast be used?</a> </p> </blockquote> <pre><code>class b { } class d :public b { } int main { d* d_p = new d(); b* b_p = static_cast&lt;base*&gt;(d_p); b* b_p = reinterpret_cast&lt;base*&gt;(d_p); // any difference will it make return 0; } </code></pre> <p>So in the above example does static and reinterpret cast make any difference functionaly etc..? for me both are same in this scenario.</p>
c++
[6]
1,255,493
1,255,494
Advantages for using php compared to asp
<p>What are the advantages of using php over asp</p>
php
[2]
2,032,677
2,032,678
How to make return value 0 of a script
<p>I have a script that triggers another script:</p> <pre><code>exit_status = subprocess.call([RUN_SCRIPT)] if exit_status: # if successful output # do something else: # if script is not successful # send email to admins # RUN_SCRIPT if return_value &lt; error_threshold: # return exit status = 1 if return_value &gt; error_threshold: # return exit status = 0 </code></pre> <p>How would I do this?</p>
python
[7]
5,094,738
5,094,739
How to do it right : embedding a png directory to an android project and reffering to its items
<p>what i did was that i added a directory named Images, which is full of png files to src\ (so all the images are in src\Images and then reffered to it in code like this:</p> <pre><code>BitmapFactory.decodeFile("Images\\"+i+".png"); </code></pre> <p>it didnt work, how can it be done correctly?</p>
android
[4]
2,063,084
2,063,085
How to work on latest sdk and support older ones
<p>I need to suppoert api level 10, and working with latest sdk to provide new device features (only if sdk of device is new). on manifest I choose min version 10. </p> <p>The problem is that the application is not installed succesfully on the old sdk devices. Whne I debug on those devices it works, The installation of signed aok fails.</p> <p>Any suggestions?</p>
android
[4]
5,373,921
5,373,922
using event load with .on() on a text field is not working
<p>im trying to trigger a load event (for example set default value) on my textfield using this:</p> <pre><code> $("#textfield1").on("load" , function(){ $("#textfield1").val("WEEE"); }); </code></pre> <p>which won't work.</p> <p>If i do this:</p> <pre><code> $(document).ready(function() { $("#textfield1").val("WEEE"); }); </code></pre> <p>or this:</p> <pre><code> $("body").on("load" , function(){ $("#textfield1").val("WEEE"); }); </code></pre> <p>then i get the desired effect. am i using the <code>load</code> wrongly in the first snippet?</p>
jquery
[5]
3,238,419
3,238,420
Where to place jQuery.expr code?
<p>I'm looking for a solution to have a case-insensitive version of the <code>:contains</code> selector in jQuery. I found these two posts here on Stack Overflow:</p> <p><a href="http://stackoverflow.com/questions/187537/is-there-a-case-insensitive-jquery-contains-selector">Is there a case insensitive jQuery :contains selector?</a><br> <a href="http://stackoverflow.com/questions/2196641/how-do-i-make-jquery-contains-case-insensitive">How do I make jQuery Contains case insensitive?</a></p> <p>So basically the solution is this:</p> <pre><code>jQuery.expr[':'].Contains = function(a,i,m){ return jQuery(a).text().toUpperCase().indexOf(m[3].toUpperCase())&gt;=0; }; </code></pre> <p>My only question is how do I use this? Where to I specify this piece of code? I'm loading jQuery in my header and afterwards I load my script.js file where I have my DOM ready function declared. I put this piece of code outside the DOM ready function but it doesn't change anything in the behaviour of the <code>:contains</code> selector.</p>
jquery
[5]
474,321
474,322
android webview virtualkey board
<p>I have a URL where User can Input in a Field.</p> <p>When I open that URL with the Android Browser and click in the Field the Virtual Keyboard pops up. When I open the same URL with my WebView and click in the Field the Virtual Keyboard does NOT appear?!</p> <p>What Do I have to do? my code is below </p> <p>LayoutInflater factory = LayoutInflater.from(InviteFriends.this); textEntryView = factory.inflate(R.layout.link, null);</p> <pre><code> builder = new AlertDialog.Builder(InviteFriends.this); builder.setTitle("Web view"); builder.setView(textEntryView); wvLink = (WebView) textEntryView.findViewById(R.id.wv); wvLink.getSettings().setJavaScriptEnabled(true); wvLink.loadUrl("http://www.google.com"); wvLink.requestFocus(View.FOCUS_DOWN); wvLink.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return true; } }); builder.setNegativeButton("oK", new DialogInterface.OnClickListener() { public void onClick( DialogInterface dialog, int which) { try { if (type == 0) { } } catch (Exception e) { e.printStackTrace(); } } }); alert = builder.create(); alert.show(); </code></pre> <p>Thanks in advance</p>
android
[4]
3,778,448
3,778,449
JAVA + create HashMap in place of function
<p>I write the following two functions I want to implement the functions with HashMap ( in place of functions ) how to do that?</p> <pre><code>static void someFunction(int count, int[] anArray) { for ( int i=0;i&lt;anArray[count];i = i + 1) { System.out.print("#"); } System.out.println(""); } static void someFunctionB(int[] anArray , int count, String stringfinal, String sttr) { anArray[count]= stringfinal.replaceAll("[^"+sttr+"]", "").length(); } someFunctionB(anArray , count, stringfinal, sttr ); someFunction(count, anArray); </code></pre>
java
[1]
2,699,705
2,699,706
I've been using dictionary keys as membership markers. Is this a good idea?
<p>For instance, I have a document that has a pile of control codes that I need to manually specify replacements for. I basically write a script that prints out the list of codes. Easy. </p> <p>Now I've been using a dictionary's key to store the membership. If the code exists, then I set the dictionary value to something, and then I just return the keys of that dictionary. This strikes me as a little wasteful. Is there any better way of doing things? </p>
python
[7]
2,585,334
2,585,335
.Net Tracking Shipments
<p>I have a situtation where a user will enter in a tracking number and i need to be able to figure out which company it was shipped from (UPS, FedEX, USPS, DHL) and then pass back a url that they can click on and send them to the right website. Any suggestions?</p> <p>Thanks Erik</p>
c#
[0]
1,057,978
1,057,979
Key combination without modifier keys
<p>I need to get key combinations like "A" &amp; "B" , "S" &amp; "D" &amp; "F" like that in C#. I can implement key combinations using modifier keys,like Control, Alter. But here, I need the key combinations without using those modifier keys.</p>
c#
[0]
3,610,613
3,610,614
jquery pass parameter to custom validation function
<p>I wrote a custom method to validate whether price is valid. Eg. no alphabet etc. Hence I wrote a custom method. But I have no idea how to pass in value.</p> <p>Method:</p> <pre><code>function checkIsPriceValid(input) { alert(input); return false; } </code></pre> <p>The form validation</p> <pre><code>$(function () { jQuery.validator.addMethod("checkIsPriceValid", function (value, element) { return checkIsPriceValid(); //check whether checkbox dist and algo is checked }, "Invalid number"); $("#addProductForm").validate({ errorPlacement: function (error, element) { //error.appendTo(element.prev()); error.insertAfter(element); }, rules: { productName: { required: true }, productCategory:{ required: true }, productDescription: { required: true }, productOrginalPrice:{ required: true, checkIsPriceValid: this.val() } </code></pre>
jquery
[5]
2,053,942
2,053,943
Run time the user control content not displaying to the page
<p>I have a few user controls, and on ASPX page on some drop down selection change i am adding user control this way, the user contorl not being displayed what i am unable to fix on it, please let me know where i am going wrong.</p> <p>partial code</p> <pre><code> switch (ContentTypeID) { case 1: UserControl uc = new UserControl(); //string ID = "1"; //string userControl ="UC" + ID + ".ascx"; //uc = LoadControl(userControl) as UserControl; //PlaceHolder1.Controls.Add(uc); uc.LoadControl("~/Controls/DocumentSpreadSheet.ascx"); //Control myUserControl = (Control)Page.LoadControl("~/Controls/DocumentSpreadSheet.ascx"); pnlDetails.Controls.Add(uc); break; case 2: break; case 3: </code></pre>
asp.net
[9]
3,077,052
3,077,053
Get content from a url using php
<p>I want to get the dynamic contents from a particular url:</p> <p>I have used the code </p> <pre><code>echo $content=file_get_contents('http://www.punoftheday.com/cgi-bin/arandompun.pl'); </code></pre> <p>I am getting following results:</p> <pre><code>document.write('"Bakers have a great knead to make bread." ') document.write('© 1996-2007 Pun of the Day.com ') </code></pre> <p>How can i get the string <strong>Bakers have a great knead to make bread.</strong> Only string inside first document.write will change, other code will remain constant</p> <p>Regards,</p> <p>Pankaj</p>
php
[2]
1,393,033
1,393,034
How to call a method from a certain java thread
<p>currently I am working on java client/server chat app and got one question, I'll try to explain as clear as possible</p> <p>My server part keeps creating threads (new ServerThread) for each user who comes online</p> <pre><code>while (isRunning) { Socket socket = serverSocket.accept(); DataOutputStream dout = new DataOutputStream(socket.getOutputStream()); outputStreams.put(socket, dout); System.out.println (outputStreams.values()); new ServerThread(this, socket); window.newConnectionInfo(socket);// informace } </code></pre> <p>I have a getter method in a ServerThread class, which I want to call from the certain ServerThread instance based on socket. But ServerThread class isn't assigned to any variable, so I don't know exactly how to call methods from it. Any solution on that?</p>
java
[1]
1,688,044
1,688,045
c#: Check which project is calling class library
<p>I have two projects which is calling a Class Library. Can i in my Class Library check which project is calling the Library?</p>
c#
[0]
269,627
269,628
What is binary compatibility
<p>I was reading <a href="http://rads.stackoverflow.com/amzn/click/0321356683" rel="nofollow">Effective Java</a> by Joshua Bloch.</p> <p>In Item 17: Use interfaces only to define types, I came across the explanation where it is not advised to use Interfaces for storing constants. I am putting the explanation below.</p> <p><em><strong>"Worse, it represents a commitment: if in a future release the class is modified so that it no longer needs to use the constants, it still must implement the interface to ensure binary compatibility."</em></strong></p> <p>What does bianry compatibility mean here?</p> <p>Can someone guide me with an example in Java to show that code is binary compatible.</p>
java
[1]
5,844,970
5,844,971
how to Upload image before text
<p>Adding <code>Checkboxes</code> and <code>RadioButton</code>s and aslo i want add image before text </p> <p>please see in this <a href="http://developer.android.com/guide/topics/ui/dialogs.html" rel="nofollow">http://developer.android.com/guide/topics/ui/dialogs.html</a></p> <pre><code>final CharSequence[] gender = {"Gmail","Facebook","Twitter","Exit"}; AlertDialog.Builder alert = new AlertDialog.Builder(DetailPage.this); alert.setTitle("Select Type"); alert.setCancelable(false); alert.setSingleChoiceItems(gender,-1, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { if(gender[which]=="Gmail") { } } } </code></pre> <p>This is my Source code i want to add gmail ,facebook and twitter icon before its text can You </p> <p>please tell me how i'll do this please post code according to my code i have tried much but </p> <p>not able to understnd. Help me</p> <p>Thanx </p>
android
[4]
2,720,973
2,720,974
How do I get an image to display on a page when the path for the image is in a MySql database?
<p>Here is the 'id' and (path) 'name' in the MySql table called "upload":</p> <pre><code> rec_id | name --------+------------------------------------------------------ 1 | C:\Apache Tomcat 5.0.28\htdocs\ajax\images\blob1.jpg 2 | C:\Apache Tomcat 5.0.28\htdocs\ajax\images\blob3.jpg 3 | C:\Apache Tomcat 5.0.28\htdocs\ajax\images\blob2.jpg </code></pre>
php
[2]
4,607,793
4,607,794
How do I dynamically invoke a certain Activity based only on the parent?
<p>I have a class in my project that is used as a helper throughout all my Activities. On the <code>onCreate</code> method, I instanciate this class like this:</p> <pre><code>MyClass myClass = new MyClass(getApplicationContext()); </code></pre> <p>Now, the MyClass class holds the context of the one who instantiated it.</p> <p>At some moment of this class, depending on what value I have computed, I want to refresh the Activity that instantiated the class. Right now I am doing the following:</p> <pre><code>Intent myIntent = new Intent(parentContext, LoginActivity.class); parentContext.startActivity(myIntent); </code></pre> <p>As you can see, I am hard coding the <code>LoginActivity.class</code>. What I want to achieve really is to start the activity based on the context. Something like this:</p> <pre><code>Intent myIntent = new Intent(parentContext, parentContext.getActivity().getClass()); </code></pre> <p>Does that make sense? I want to be able to dynamically refresh any activity that has given its context to the class. Is that possible?</p> <p>Or maybe I should think of a different design?</p> <p>Many thanks, Felipe</p>
android
[4]
5,478,768
5,478,769
setting cookie.domain in asp.net
<p>Trying to set a domain in the cookie in asp.net and I am very novice in asp.net so wanted to know how this can be done.</p> <p>here is my code</p> <pre><code>// Create cookie var cookieData = new NameValueCollection(); cookieData["first_name"] = first_name; cookieData["last_name"] = last_name; var cookie = new CookieHeaderValue("UserInfo", cookieData); cookie.Expires = DateTimeOffset.Now.AddDays(1); //cookie.Domain = Request.RequestUri.Host; cookie.Domain = "example.com"; cookie.Path = "/"; </code></pre> <p>Need to set the cookie to work for srv1.example.com &amp; srv2.example.com </p> <p>currently running through Visual Basic and using Request.RequestURI.Host gives me the domain as localhost.</p>
asp.net
[9]
5,598,218
5,598,219
matching url to another url
<p>I am faced with rather unusual situation</p> <p>I will have url in any of the 3 formats:</p> <ol> <li><a href="http://example.com/?p=12" rel="nofollow">http://example.com/?p=12</a></li> <li><a href="http://example.com/a-b/" rel="nofollow">http://example.com/a-b/</a></li> <li><a href="http://example.com/a.html" rel="nofollow">http://example.com/a.html</a></li> </ol> <p>Now, I need to match with a url like</p> <ol> <li><a href="http://example.com/?p=12&amp;t=1" rel="nofollow">http://example.com/?p=12&amp;t=1</a></li> <li><a href="http://example.com/a-b/?t=1" rel="nofollow">http://example.com/a-b/?t=1</a></li> <li><a href="http://example.com/a.html?t=1" rel="nofollow">http://example.com/a.html?t=1</a></li> </ol> <p>How can I achieve this? Please help</p> <p>I know I can use like:</p> <pre><code>stristr('http://example.com/?p=12','http://example.com/?p=12&amp;t=1') </code></pre> <p>but this will also match when</p> <pre><code>http://example.com/?p=123 (as it matches p=12) </code></pre> <p>Help guys, please.</p>
php
[2]
4,464,291
4,464,292
long running php script issue on firefox/IE
<p>I am executing one php script, which is taking around 8 minutes to execute. this code is working fine on chrome, but on IE/Firefox it is not working. In the chrome, i am getting the output after 8 minutes, but in IE/Firefox i am not getting any response.</p> <p>What could be issue? Please help on that. any issue with browser/header.</p>
php
[2]
1,069,063
1,069,064
checking for set gpr?
<p>What would be best practice in check for set get/post/request?</p> <p>right now i am doing</p> <pre><code>if(!isset($_GET['account']) || !isset($_GET['ssid']) || !isset($_GET['mssid']) || !isset($_GET['max'])) { die("missing info"); } if($_GET['account'] == "" || $_GET['ssid'] == "" || $_GET['mssid'] == "" || $_GET['max'] == "") { die("missing info"); } </code></pre> <p>I assume this is horrendous and very bad to do... can't seem to figure out the 'accepted' way to do this</p>
php
[2]
5,433,477
5,433,478
Why does Crockford say not to use the new keyword if he advises us to use it for prototypal inheritance?
<p>I saw a video in which Crockford told us not to use the <code>new</code> keyword. He said to use Object.create instead if I'm not mistaken. Why does he tell us not to use <code>new</code> if he has used it in achieving prototypal inheritance in this article that he wrote: <a href="http://javascript.crockford.com/prototypal.html">http://javascript.crockford.com/prototypal.html</a></p> <p>I would expect him to use Object.create instead of <code>new</code>, like this:</p> <pre><code>function object(o) { return Object.create((function() {}).prototype = o); } </code></pre> <p>So why is it that he still uses <code>new</code>?</p>
javascript
[3]
291,242
291,243
Bluetooth-Android ICS Base build
<p>I build android ICS base software for emulator. This builds ok. Then, I have modified the c files in the path: “external\bluetooth\bluez\attrib\gattrip.c.” Also other c files in this location. I am not sure how do I build this file on ICS base.</p> <p>Before I build I build for Emulator successfully I have used the commands as shown below:</p> <p>source build/envsetup.sh lunch full-eng make –j4</p> <p>Do I need to build NDK build for these files, if yes how do I do this? Also could you kindly let me know how do I build this c files and how do I check this has been build successfully.</p> <p>Regards and thanks</p>
android
[4]
1,642,917
1,642,918
android : SQL Exception while querying
<p>Team,</p> <p>Can you please help me to understand why I m getting the following exception.</p> <p>05-07 10:57:20.652: ERROR/AndroidRuntime(470): android.database.sqlite.SQLiteException: near "1": syntax error: , while compiling: SELECT Id,Name FROM act WHERE Id 1-IJUS-1</p> <p>Thanks in advance,</p>
android
[4]
2,389,702
2,389,703
Specifiying keyword arguments with *args and **kws
<p>I've found a behavior in Python that has baffled and irritated me and I was wondering what I got wrong...</p> <p>I have a function which should take an arbitrary number of arguments and keywords, but in addition should have some default-valued keywords that comprise it's actual interface:</p> <pre><code>def foo(my_keyword0 = None, my_keyword1 = 'default', *args, **kws): for argument in args: print argument </code></pre> <p>The problem is that if I try calling <code>foo(1, 2, 3)</code> I'll only get the printout for 3 and the values 1 and 2 will override my keyword arguments.</p> <p>On the other hand if I try moving my keywords after the <code>*args</code> or after the <code>**kws</code> it will cause a syntax error. The only solution I found to the problem was to extract the keyword arguments from <code>**kws</code> and setting default values to them:</p> <pre><code>def foo(*args, **kws): my_keyword0 = None if 'my_keyword0' not in kws else kws.pop('my_keyword0') my_keyword0 = 'default' if 'my_keyword1' not in kws else kws.pop('my_keyword1') for argument in args: print argument </code></pre> <p>This is horrible both because it forces me to add pointless code and because the function signature becomes harder to understand - you have to actually read the functions code rather than just look at its interface.</p> <p>What am I missing? isn't there some better way to do this?</p>
python
[7]
4,855,207
4,855,208
Which JS Framework Can Store Datas Like DBs Does?
<p>I need to store datas like DBs does on client-side in JS, </p> <pre><code>db.insert(unique_key,{ a : 20, b : 30 }) ; db.select('a&gt;10') ; </code></pre> <p>This is just illustrative syntax to show,</p> <p>How can I procces datas more than key/value pair do.</p> <p>Any acknowledge would be great,</p> <p>Thank you!</p>
javascript
[3]
3,873,167
3,873,168
Fragment over another fragment issue
<p>When I'm showing one fragment (which is full screen with <code>#77000000</code> background) over another fragment (let's call it main), my main fragment still reacts to clicks (we can click a button even if we don't see it).</p> <p><strong>Question</strong>: how to prevent clicks on first (main) fragment?</p> <p><strong>EDIT</strong></p> <p>Unfortunately, I can't just hide main fragment, because I'm using transparent background on second fragment (so, user can see what located behind).</p>
android
[4]
4,274,837
4,274,838
Progress Bar + Main Thread UI Update Wait for Thread to complete (Android Java)
<p>I have been getting help to create a progress bar for my Android application. Lots of help here! I'm having an issue though that I am having a hard time fixing. I have a progress bar shown while the application attempts to download files from a networked computer. This works perfectly fine, however I need to update my UI incase an error occurs. I can't update the UI inside the thread and I want to update the UI from getRaceResultsHandler. Unfortunately it executes that code prior to the thread being completed. I have tried a few things with no luck. I have a code sample with my comments below if anyone can help.</p> <pre><code>public void getRaceResultsHandler (View view) { dialog = new ProgressDialog(this); dialog.setCancelable(true); dialog.setMessage("Attempting to transfer race files. Please wait..."); // Set progress style to spinner dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); // display the progressbar dialog.show(); // create a thread for downloading the files Thread background = new Thread (new Runnable() { public void run() { //The Code here to execute the file download from the networked computer.... //Dismiss the progress bar because the download is either completed or failed... dialog.dismiss(); } }); // start the background thread background.start(); //All Other Code Goes here to update the UI. Shows either an error message or a success based on the results of the download. //My problem is that this code executes before the background thread is completed. I need it to wait until the thread is completed. } </code></pre>
android
[4]
720,496
720,497
Using volume buttons while in sleep mode ( music player style )
<p>I need to use volume buttons in my application while sleep mode is active( black screen, locked). I am using onDispachKeyEvent to capture volume buttons and it works perfectly while in normal state. In music player if you close the screen, you can still change volume. Any idea how is done ?</p> <p>Thanks</p>
android
[4]
1,803,735
1,803,736
show/hide the corresponding part content of li?
<p>the hmtl code: </p> <pre><code> &lt;div id="nav"&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="#"&gt;test 1&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;test 2&lt;/a&gt; &lt;div class="sub-nav"&gt; &lt;p&gt; &lt;a href="#"&gt;link &lt;/a&gt; &lt;a href="#"&gt;link &lt;/a&gt; &lt;a href="#"&gt;link &lt;/a&gt; &lt;/p&gt; &lt;/div&gt; &lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;test 3&lt;/a&gt; &lt;div class="sub-nav"&gt; &lt;p&gt; &lt;a href="#"&gt;link2 &lt;/a&gt; &lt;a href="#"&gt;link3&lt;/a&gt; &lt;a href="#"&gt;link4 &lt;/a&gt; &lt;/p&gt; &lt;/div&gt; &lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;test 4&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; </code></pre> <p>i want to do when the mouse hover on the <strong>li</strong>, it will show the corresponding part content(<code>sub-nav</code>). when the mouse move off the li, the corresponding part will be hidden.</p> <pre><code>.sub-menu css is display:none; </code></pre> <p>the following is my code, but doesn't work. </p> <pre><code>$(function(){ $("#nav ul li").mouseenter(function() { $(this).find(".sub-menu").show(); }); }); </code></pre>
jquery
[5]
427,825
427,826
jquery mouseover events
<p>How could I keep this working constantly. The mouseover works only once, but I'd like it to work at all times.</p> <pre><code> if (!self.options.overlapEventsSeparate) { $(this).bind('mouseover.z-index', function() { var $elem = $(this); $.each(curGroup, function() { $(this).css({'z-index': '1'}); }); $elem.css({'z-index': '3'}); }); } </code></pre> <p>Thanks!</p>
jquery
[5]
4,207,149
4,207,150
manually adding users to roles in asp.net
<p>i have googled the heck out of this and i cannot find a solution. i would like to add users to a role manually using the administration tool or just manually doing this. i am a beginner with asp.net, how would i do this? i am using windows authentication</p>
asp.net
[9]
437,582
437,583
How can you round up a number and display it as a percentage?
<p>I'm a bit rusty on my mathematics so I hope someone can help me. Using the code below I would like to do the following: Depending on the amount of memory installed, I would like to display the percentage of available memory and not how much is left in megabytes.</p> <pre><code>private void timer1_Tick(object sender, EventArgs e) { string memory; int mem; memory = GetTotalMemoryInBytes().ToString(); mem = Convert.ToInt32(memory); mem = mem / 1048576; progressBar2.Maximum = mem; progressBar2.Value = mem - (int)(performanceCounter2.NextValue()); label2.Text = "Available Memory: " + (int)(performanceCounter2.NextValue()) + "Mb"; } //using Microsoft visual dll reference in c# static ulong GetTotalMemoryInBytes() { return new Microsoft.VisualBasic.Devices.ComputerInfo().TotalPhysicalMemory; } </code></pre>
c#
[0]
5,335,230
5,335,231
Javascript clear content of selectbox
<p>As part of my populating selectbox function I am clearing the contents of the populated select box and then inserting options to a empty box. Although the select box is not being cleared correctly and a lot of options are not removed. I am using the following code to clear the contents of the select box:</p> <pre><code>for(var i = 0; i &lt; document.getElementById(selectbox).options.length; i++) document.getElementById(selectbox).options[i] = null; </code></pre> <p>Why not all the options are removed from the selectbox?</p>
javascript
[3]
614,996
614,997
how to fetch URL data
<p>i have created custom query which i am sending via POST ajax but problem with it is that how to retrieve that data</p> <p>i am sending this query = <code>rep_id=4&amp;filter=&amp;filter_val=&amp;rep_id=5&amp;filter=&amp;filter_val=&amp;rep_id=6&amp;filter=&amp;filter_val=&amp;from=p_employee_mst</code></p> <p>and here is the function to fetch that query in PHP</p> <pre><code>$rep=""; foreach ($_POST["rep_id"] as $k =&gt; $v) { $rep[]=$v; } print_r($rep); </code></pre> <p>i am getting following error </p> <p><strong>Invalid argument supplied for foreach()</strong></p> <p>if print_r($_POST); i am getting this</p> <pre><code>Array ( [rep_id] =&gt; 6 [filter] =&gt; [filter_val] =&gt; [from] =&gt; p_employee_mst ) </code></pre>
php
[2]
2,475,920
2,475,921
how do I get the name of a running python script?
<p>I tried <code>os.__file__</code> but that returns the name of the file where <code>os</code> resides.</p>
python
[7]
500,200
500,201
How to debug the android app from eclipse to samsung galaxy pop?
<p>I'm using Samsung galaxy pop. I want to debug the application from eclipse to device. This will be working fine to my HTC mobile. But whenever I was connected the samsung android device, it's not connected to my eclipse. </p> <p>How to resolve this issue?</p> <p>Thanks in advance..</p>
android
[4]
4,580,673
4,580,674
Passing with Accessors in C#
<p>I am having a bit of trouble passing variable between forms. I have created a button array and want to pass the button text to the next form. But this is just returning a Null value</p> <p>In the first form</p> <pre><code>private string staffmem; public string Staffmem { get { return staffmem; } } public void ClickButton(Object sender, EventArgs e) { Button btn = (Button)sender; staffmem = btn.Text; MessageBox.Show("Welcome " + staffmem); MainScreen ms = new MainScreen(); ms.Show(); } </code></pre> <p>and then in the second form</p> <pre><code> private void MainScreen_Load(object sender, EventArgs e) { Form1 f1 = new Form1(); staffmem = f1.Staffmem; </code></pre> <p>Any help would be much appreciated. Thanks in advance</p>
c#
[0]
836,126
836,127
Is there thing like pass by value pass by reference in JavaScript?
<p>When i started learning function in C++ its all around pass by value and reference. Is there something similar we have in javascript ?</p> <p>If yes/not how it works in case of javascript?</p> <p>Thanks all.</p>
javascript
[3]
3,614,555
3,614,556
Members not available when implementing IList
<p>I've tried to create a simple class implementing IList. However the members are not available unless I first cast DiskBackedCollection to IList. How can I make it usable without casting?</p> <pre><code>public partial class DiskBackedCollection&lt;T&gt; : IList&lt;T&gt; { private List&lt;T&gt; _underlyingList = new List&lt;T&gt;(); int IList&lt;T&gt;.IndexOf(T item) { return _underlyingList.IndexOf(item); } T IList&lt;T&gt;.this[int index] { get { return _underlyingList[index]; throw new NotImplementedException(); } set { throw new NotImplementedException(); } } int ICollection&lt;T&gt;.Count { get { return _underlyingList.Count; } } IEnumerator&lt;T&gt; IEnumerable&lt;T&gt;.GetEnumerator() { return new DiskBackedCollectionEnumerator(this); } IEnumerator IEnumerable.GetEnumerator() { return new DiskBackedCollectionEnumerator(this); } } </code></pre>
c#
[0]
1,690,432
1,690,433
Jquery document off mouseevent
<p>Start</p> <pre><code>$(document).on('mousemove', "#id", EVENT); </code></pre> <p>Disable</p> <pre><code>$(document).off('mousemove', "#id"); </code></pre> <p>I have tried...</p> <pre><code>$(document).off('mousemove', "#id", EVENT); $("#id").unbind('mousemove'); </code></pre> <p>Exact Functions</p> <pre><code>$(document).on('click', "#id", function (e) { $(document).on('mousemove', "#id", EVENT); }); $(document).on('mouseup', function () { console.log('test'); $(document).off('mousemove', "#id"); }); </code></pre> <p>What am I doing wrong?</p>
jquery
[5]
3,662,087
3,662,088
Check html element's click event fired programmatically or by clicking with mouse
<p>I must check which is fired the click event, click with mouse or .click() function. Is it possible?</p>
jquery
[5]
509,348
509,349
Accessing the same service more than twice in the nick of time
<p>I have an application that will access interface service A which is to run from windows startup. This service is used by program B and my application functions on B's presence after getting a pointer to A. The scenario is translated as follows,</p> <pre><code>public interface A{} ///my program public class MyProgram { public MyProgram() { ProgramB.DoA(); } public A GetA(){} } public class ProgramB { void DoA(){} } </code></pre> <p>The translated source is not true, but that seems to be what I am looking for. In order to eliminate the overhead of allocating and realocating dynamic accesses to the same service used by other processes, would you please provide an actual solution to the problem ?(I am all out of any idea now)</p>
c#
[0]
3,285,085
3,285,086
How do I know when a GLSurfaceView is fully initialized from the Activity?
<p>I have an Activity that contains several views. One of which is a GLSurfaceView. This GLSurfaceView displays pretty 3D effects based on what is selected in my Activity's other views (ListViews, EditTexts, etc). The issue I am having is that I don't know when my GLSurfaceView has been fully initialized from the Activity.</p> <p>I began by simply attempting to pass my graphics data to my GLSurfaceView in my Activity's onCreate() method shortly after the setContentView() method. This worked fine on the emulator but on several devices this fails with null pointer exceptions from attempting to access objects that had not even been constructed yet. I assumed it was because my view had not been inflated yet and perhaps inflating views just takes longer on my devices.</p> <p>I scattered some logging just to see the order of things and I found that my GLSurfaceView's onSurfaceCreated method is called well after the GLSurfaceView's onFinishInflate method.</p> <p>So now I am looking for a good way to determine in my Activity when my GLSurfaceView's onSurfaceCreated method has been called so that I can safely tell my GLSurfaceView what to draw.</p>
android
[4]
1,670,394
1,670,395
char printable program
<p>i have program which prints all char from char_min to char_max here is code</p> <pre><code>#include &lt;limits.h&gt; #include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; int main(){ char c; c=CHAR_MIN; while(c!=CHAR_MAX){ printf("d\n",c); c=c+1; } return 0; } </code></pre> <p>but it prints only all d why?ouput is like this</p> <pre><code>d d d d d d d d d d </code></pre> <p>...</p> <p>. . press any key to continue</p>
c++
[6]
2,618,329
2,618,330
Python: Sort custom class without use of `key` argument?
<p>You can sort an array of <code>myclass</code> by using the <code>key</code> argument to the <code>sorted</code> function:</p> <pre><code>sortedlist = sorted(myclasses, key=lambda obj: obj.myproperty) </code></pre> <p>Is there a way to define a natural ordering for our class? Perhaps some magic method so that we don't have to pass in a key each time?</p> <p>e.g.,</p> <pre><code>class myclass: def __init__(self,a,b): self.key1 = a self.key2 = b def __sortkey__(self): return self.key2 </code></pre> <p>Or will it naturally work if we define <code>__le__</code> perhaps?</p>
python
[7]
2,254,660
2,254,661
c++ makefile importance and cross platform
<p>I'm new to c++ and I wanted to know few questions regarding makefile.</p> <p>1) Is writing makefile really important ? I mean there are many IDE's which does this automatically. Also, do people in programming job write makefiles or do they use automation?</p> <p>2) Should I learn GNU make or something else like cmake or other ? Can anyone point of pros and cons of these?</p>
c++
[6]
997,456
997,457
java parsing string as properties
<p>I am reading a properties file from database. I checked java properties, there's no method to parse from string. Is there any other efficient way to parse this? Thank you very much.</p>
java
[1]
1,483,026
1,483,027
how to display the same value into another class's textfield?
<p>hi all i have implemented code as shown in the below here problem is when i clicked on click event textfield *settextvalue value is not appearing into the next view textfield for this give me the solution in iphone. </p> <p>ClassA.h</p> <pre><code>@classB { UITextField *settextvalue; ClassB *b; } @property(nonatomic,retain)UITextField *settextvalue; @property(nonatomic,retain)ClassB *b; @end ClassA.m { @ synthesize b,settextvalue; -(void)viewDidload{ b = [[ClassB alloc]init]; settextvalue.text=@"333"; } -(IBAction)resultOfvalue{ [self.view addSubview:[b view]]; settextvalue.text = b.resultyear.text; } Class B.h { UITextField *resultyear; } @property(nonatomic,retain)UITextField *resultyear; @end Class B.m { @synthesize resultyear; } </code></pre>
iphone
[8]
225,283
225,284
send email after validation
<p>hi i am new enough to JavaScript and am wonder how to send details in email after validation ,heres my code </p> <pre><code>&lt;script type="text/javascript"&gt; var compName=false; var compContry=false; var compsub=false; var compphone=false; var compemail=false; function validate_form(form) { if(compName) { document.getElementById('country').focus(); compName=true; if(compContry) { document.getElementById('subject').focus(); compContry=true; if(compsub) { document.getElementById('Phone').focus(); compsub=true; if(compphone) { document.getElementById('email').focus(); compphone=true; if(compemail) { //I just use alert to show it works. alert("Your Details Are Sent "); compemail=true; } else { document.getElementById('email').focus(); compemail=false; } } else { document.getElementById('Phone').focus(); compphone=false; } } else { document.getElementById('subject').focus(); compsub=false; } } else { document.getElementById('country').focus(); compContry=false; } } else { document.getElementById('username').focus(); compName=false; } } </code></pre>
javascript
[3]
3,866,117
3,866,118
Windows system time with millisecond precision, UP
<p>I want to reask <a href="http://stackoverflow.com/questions/3140826/windows-system-time-with-millisecond-precision">this</a> question as it was asked two years ago and I think probably now better solutions exist.</p> <p>So I just need to have DateTime.Now with millisecond precision. At the same time I do not want to change global <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/dd757624%28v=vs.85%29.aspx" rel="nofollow">timeBeginPeriod</a> not to affect other application and not to degreed overall system perfomance. Should I just use <code>DateTimePrecise</code> class from the referenced question?</p>
c#
[0]
4,355,837
4,355,838
Is there a limit to the amount of elements in a Vector in Java?
<p>Does the Vector class of Java have a limit to the amount of elements it can store? I know it automatically grows and should be able to store an arbitrary amount of elements, however are there any limitations that limit the amount of elements you can actually store? Other than the most obvious limitation like running out of memory.</p>
java
[1]
3,079,556
3,079,557
Is the way I have my admin panel set up good?
<p>So basically, <a href="http://github.com/a2h/Ze-Very-Flat-Pancaek-CMS/blob/1630d6337d93fd7cc7612020ac136fb3edef8b00/trunk/zvfpcms/admin/admin.php" rel="nofollow">this</a> is what I have.</p> <p>But is this a good practice? I started splitting up my admin.php file due to it growing in size.</p> <p>However, I have a slight concern over how many files I could potentially end up with, and also problems to work with in case something may need to be updated over all the files.</p>
php
[2]