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,960,704 | 3,960,705 | Jquery - hide() then fadeIn() then fadeOut() is there a cleaner way? | <p>I'm trying to achieve some animation using jQuery. I have it working but I'm 100% sure there is a cleaner better way of doing and I'm hoping someone can point me in the right direction.</p>
<p>Here is my code:</p>
<pre><code>$(document).ready(function () {
$("#1-popup").hide(); // Hides the first popup
$("#2-popup").hide(); // Hides the second popup
$("#1-trigger").toggle(function () {
$("#2-popup").fadeOut("slow"); // Hides the second popup just incase its showing
$("#1-popup").fadeIn("slow"); // Fades in the first popup
}, function () {
$("#1-popup").fadeOut("slow"); // Fades out in the first popup
});
$("#2-trigger").toggle(function () {
$("#1-popup").fadeOut("slow"); // Hides the first popup just incase its showing
$("#2-popup").fadeIn("slow"); // Fades in the second popup
}, function () {
$("#2-popup").fadeOut("slow"); // Fades out the second popup
});
});
</code></pre>
<p>Its a little messy is there anyway to use an if statement in this?</p>
| jquery | [5] |
3,662,828 | 3,662,829 | iphone - is it possible to do push notification service with adobe flash cs3? | <p>just like in the title, is it possible to do push notification service with adobe flash cs3 ? *sending a push notification via flash to an iPhone, maybe in javascript?</p>
| iphone | [8] |
3,425,397 | 3,425,398 | How do I stop an infinite animation on an ImageView, but let it complete its current cycle? | <p>I applied an infinite animation on an ImageView to indicate a running background thread in my app. When the thread finishes, I'm able to stop the animation by using clearAnimation(), but it snaps the ImageView back to its starting position, and I'd like the current animation cycle to complete (which is designed to gracefully end in its starting position). Is there a way to do this?</p>
| android | [4] |
1,141,532 | 1,141,533 | C++ syntax help dealing with recursive definition (or so my compiler tells me) | <p>I'm building a game and I was compiling seeing what sort of errors were coming up and there is one there is very common and very puzzling to me:</p>
<pre><code>1>c:\users\owner\desktop\bosconian\code\bosconian\ship.h(9) : error C2460: 'Ship::Coordinate' : uses 'Ship', which is being defined
</code></pre>
<p>This also comes up for the SpaceObject class and all other derivations of it. The Coordinate class is simply just a 2d vector class and, if it matters, references nothing but an Environment class.</p>
<p>The Environment class references the SpaceObject's but I don't believe that's a problem (correct me if I'm wrong)</p>
<p>This is my first larger scale project in C++ and I was wondering if this might be a common newbie error with a more obvious solution. If it matters the SpaceObject class hierarchy is not all the way filled in, but it is filled in several levels past the SpaceObject and Ship classes.
.<br />
.<br />
.<br />
Edit: This is in response to the comment. </p>
<p>-When I say reference I mean refer to that class in another class. Like in the SpaceObject class I reference the Coordinate class:<br />
Coordinate * position</p>
<p>Environment does make reference to SpaceObject pointers, but I can't see I could not reference classes like that...I mean, all my classes have to relate to eachother in some way, right?</p>
<p>In response to pasting code, it's sort of hard because they are huge classes but here is the line the error is pointing to:</p>
<pre><code>public:
Ship(Coordinate * positionObject_, int direction_, int possibleDirections_, int maxHealth_, Component * objectSectors_, int numOfObjectSectors_, double speed_);//this is the line
void move();//handles the actual translation of calculated move on the map (i.e. bounds checking)
</code></pre>
| c++ | [6] |
4,231,326 | 4,231,327 | How can we temporary off the running website & gives a message "This site is Temprorary unavailable" | <p>How can we temporary off the running website & gives a message "This site is Temprorary unavailable", actully i want to gives a power to admin he can temporary on/Off the website... according to my need i dnt want to add web_offline.htm page. I simply do it by button control i.e. Active website & Deactive website(dynamic method)</p>
| asp.net | [9] |
5,966 | 5,967 | Offline version of java api reference docs | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/1521823/download-java-api-documentation">Download Java API Documentation?</a> </p>
</blockquote>
<p>Are there any offline version of this :</p>
<p><a href="http://download.oracle.com/javase/7/docs/api/" rel="nofollow">http://download.oracle.com/javase/7/docs/api/</a></p>
| java | [1] |
4,430,593 | 4,430,594 | $(element).on(event) vs $(ancestor).on(event, element) | <p>I've been using the latter of the below functions pretty much ever since <code>.on()</code> was added, but I've noticed recently that quite a lot of answers use the former.</p>
<p>What is the difference between:</p>
<pre><code>$(ancestor).on(event, element, function() { ... })
</code></pre>
<p>And:</p>
<pre><code>$(element).on(event, function() { ... })
</code></pre>
<p><a href="http://jsfiddle.net/DFgxw/" rel="nofollow">JSFiddle example</a>.</p>
| jquery | [5] |
935,305 | 935,306 | Variable property | <p>Is this both the same:</p>
<pre><code>private int x;
public int X
{
get { return x; }
set { x = value; }
}
</code></pre>
<p>and</p>
<pre><code>public int X
{
get { return x; }
set { x = value; }
}
</code></pre>
<p>I mean is it enough to use the second case or there are special cases I should use the first case?</p>
<p>because I sometimes see codes with first case and sometimes with second case, so i have confused</p>
| c# | [0] |
704,279 | 704,280 | Custom Design in IPhone Applications | <p>I want to create the following design to my IPhone application. I dont know any idea about this. If anybody knows any idea, please help me.</p>
<p><img src="http://i.stack.imgur.com/WPL1g.jpg" alt="alt text"></p>
<p>Thanks.</p>
| iphone | [8] |
5,916,743 | 5,916,744 | How do I use today's date in a folder path | <p>So I am creating lots of folders as part o fum jobs say and part of the naming strategy is to use today's date as part of the Path<br>
When I use DateTime.Now.ToShortDateString() I keep getting a forward slash<br>
Is there anyway to stop that or any other strategy to use the date in a temporary folder </p>
| c# | [0] |
2,438,728 | 2,438,729 | JavaScript help: Simple script won't work when calling setTimeout | <p>I want to change the exist in a span element every 2 seconds, but it showing only what is in case 0: 'asd'.</p>
<p>Could anyone tell me why this is not working? </p>
<pre><code>var n = 0;
function hideVideoSpan(type){
switch(type)
{
case 0:
{
$("#hideVideoSpan").html('asd');
n = 1;
break;
}
case 1:
{
$("#hideVideoSpan").html('lol');
n = 0;
break;
}
default:break;
}
setTimeout(hideVideoSpan(n), 2000);
}
hideVideoSpan(n);
</code></pre>
| javascript | [3] |
5,961,476 | 5,961,477 | Problem in creating LDAP user through php script | <p><strong>1.</strong> I have created user in LDAP using php script under pre defined "ou" but unable to create "ou" or "cn" through my script.
<strong>2.</strong></p>
<pre><code>// configure privileged user
$root_dn = "cn=test,dc=design,dc=com";
$root_pw = "your password";
// specify the LDAP server to connect to
$conn = ldap_connect("localhost") or
die("Could not connect to server. Error is " . ldap_error($conn));
// bind to the LDAP server
$r = ldap_bind($conn, $root_dn, $root_pw) or
die("Could not bind to server.Error is " . ldap_error($conn));
// prepare data
$info["cn"] = $_POST['cn'];
$info["sn"] = $_POST['sn'];
$info["mail"] = $_POST['mail'];
$info["userPassword"] = "testPWD";
$info["objectClass"] = "inetOrgPerson";
// prepare DN for new entry
$dn = "mail=" . $_POST['mail'] .",ou=Groups,domainName=your domaun name,o=domains,
dc=dc, dc=com";
// add data to directory
$result = ldap_add($conn, $dn, $info);
// if successful, display success message
if($result)
{
echo "New entry with DN " . $dn . " added to LDAP directory."; }
// elsedisplay error
else
{
echo "An error occurred. Error number " . ldap_errno($conn) . ": " .ldap_err2str(ldap_errno($conn)); }
// all done? clean up
ldap_close($conn);
</code></pre>
<p><strong>Issue:</strong>
After creating user successfully, I am unable to log in for viewing mail by using "mail" and "password".Though I can see new created user in "LDAP" directory list.
When I checked there was no option was enable under "enabledService" may be this is the problem...please suggest...and if yes then how to create full privileged user through php script.</p>
<p>Thanks in Advance!</p>
| php | [2] |
3,869,704 | 3,869,705 | How to stop foreach loop in a given state | <pre><code>foreach (String host in hostArray)
{
string s1 = hostArray[t];
string s2 = branchArray[t];
string con_msg;
t=t+1;
TcpClient socketForServer;
try
{
socketForServer = new TcpClient(s1, 10);
con_msg="Connected";
}
catch
{
ListViewItem item = new ListViewItem();
item.BackColor = Color.LightGreen;
item.Text = (s2);
item.SubItems.Add(s1);
item.SubItems.Add("Not found");
listView1.Items.Add(item);
con_msg = "Not connected";
// I want to exit this round in here and and start next round how to do it
}
NetworkStream networkStream = socketForServer.GetStream();
System.IO.StreamReader streamReader = new System.IO.StreamReader(networkStream);
System.IO.StreamWriter streamWriter =new System.IO.StreamWriter(networkStream);
//code
}
</code></pre>
<p>I want to exit current round in catch and start next round. how to do it. I don't want to exit foreach loop , i just want to exit from current round and start next round</p>
| c# | [0] |
4,999,494 | 4,999,495 | How to send images in MMS in Android programmaticaly | <p>I want to make Android apps for sending images using MMS. Here is the problem:</p>
<pre><code>final ConnectivityManager connMgr =
(ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
final int result =
connMgr.startUsingNetworkFeature( ConnectivityManager.TYPE_MOBILE,
Phone.FEATURE_ENABLE_MMS);
</code></pre>
<p>Phone.FEATURE_ENABLE_MMS feature is not available.</p>
| android | [4] |
3,037,860 | 3,037,861 | Show content only for organic traffic | <p>I want to show some content only for visitors from search engines,
can you help me please ? :)</p>
<p>I already have this php, but it show only for google.com but I want whole google and yahoo :)</p>
<pre><code>if(substr((trim($_SERVER['HTTP_REFERER'])), 0, 23) == "http://www.google.com/")
{
echo "Show what I want";
}
</code></pre>
| php | [2] |
3,286,901 | 3,286,902 | pure virtual and inline definition | <pre><code>struct device{
virtual void switchon()=0{}
};
int main()
{
}
</code></pre>
<p>I wrote code similar to following and it gave error.</p>
<blockquote>
<p>pure-specifier on function-definition
compilation terminated due to
-Wfatal-errors.</p>
</blockquote>
<p>When I asked him, he showed me the following quote from the Standard</p>
<blockquote>
<p>A virtual function declared in a class
shall be defined, or declared pure
(10.4) in that class, or both; but no
diagnostic is required (3.2).</p>
</blockquote>
<p>I can't seem to understand what it means and I think this somehow is not relevant. Any help in this is appreciated.</p>
<p>PS: If this is not the relevant quote, pls guide me to the proper one so that I can have a better counterargument.</p>
| c++ | [6] |
1,308,680 | 1,308,681 | How to get keyCode in android | <p>I have the following code:</p>
<pre><code>tv.setOnKeyListener(new View.OnKeyListener() {
public boolean onKey(View v, int keyCode, KeyEvent event) {
switch(keyCode)
{
case KeyEvent.KEYCODE_0:
Log.v(TAG, "Keycode_0");
return true;
//break;
case KeyEvent.KEYCODE_1:
Log.v(TAG, "Keycode_1");
return true;
//break;
case KeyEvent.KEYCODE_D:
Log.v(TAG, "Keycode_D");
return true;
//break;
case KeyEvent.KEYCODE_2:
Log.v(TAG, "Keycode_2");
return true;
//break;
case KeyEvent.KEYCODE_TAB:
Log.v(TAG, "Keycode_TAB");
return true;
//break;
case KeyEvent.KEYCODE_DEL:
Log.v(TAG, "Keycode_DEL");
return true;
//break;
case KeyEvent.KEYCODE_COMMA:
Log.v(TAG, "Keycode_COMMA");
return true;
//break;
case KeyEvent.KEYCODE_ENTER:
Log.v(TAG, "KEYCODE_ENTER");
i=KeyEvent.KEYCODE_ENTER;
Log.v(TAG, "KEYCODE_ENTER"+i);
return true;
//break;
case KeyEvent.KEYCODE_SHIFT_LEFT:
Log.v(TAG, "KEYCODE_SHIFT_LEFT"+KeyEvent.KEYCODE_SHIFT_LEFT);
return true;
//break;
case KeyEvent.KEYCODE_SHIFT_RIGHT:
Log.v(TAG, "KEYCODE_SHIFT_RIGHT"+KeyEvent.KEYCODE_SHIFT_RIGHT);
return true;
//break;
case KeyEvent.KEYCODE_SPACE:
Log.v(TAG, "KEYCODE_SPACE"+KeyEvent.KEYCODE_SPACE);
return true;
//break;
default:
break;
}
return false;
}
});
</code></pre>
<p>but it is working only for <code>enter</code> and <code>delete</code> keys. For the rest of the keys, it is not working. I wanted it for <code>shift</code> and <code>caps lock</code> keys.</p>
| android | [4] |
1,708,112 | 1,708,113 | Use php to generate snippet code of html or javascript | <p>Simply want to use php to generate snippet in javascript or html that can access images from another server if they meets criteria as they are registered and active.</p>
<p>Example.
if i have some users that have avatars if they want to embed their avatar on their own website they use snippet code generated by php app(they include snippet code in website page to show avatar that is on another server where my php app lie ).
Snippet only show their image by applying some conditions e.g where the request came from etc</p>
| php | [2] |
2,556,527 | 2,556,528 | Android.mk file for Executable: accRuntimeTest | <p>Can you please tell me where I can find the Android.mk file for Executable: accRuntimeTest?</p>
<p>I am getting the following error when I compile android source on ubuntu 9.10. I think it misses a linker flag to link a library 'dlsym', I just don't know where is the Android.mk file I should go and fix it?</p>
<pre><code>Install: out/target/product/generic/system/usr/keychars/qwerty.kcm.bin
Install: out/target/product/generic/system/usr/keychars/qwerty2.kcm.bin
Install: out/target/product/generic/system/usr/keychars/tuttle2.kcm.bin
Copy: out/target/product/generic/system/etc/apns-conf.xml
host Executable: accRuntimeTest (out/host/linux-x86/obj/EXECUTABLES/accRuntimeTest_intermediates/accRuntimeTest)
host Executable: acc (out/host/linux-x86/obj/EXECUTABLES/acc_intermediates/acc)
/usr/bin/ld: out/host/linux-x86/obj/EXECUTABLES/accRuntimeTest_intermediates/runtimeTest.o: in function symbolLookup(void*, char const*):system/core/libacc/tests/runtimeTest.cpp:66: error: undefined reference to 'dlsym'
collect2: ld returned 1 exit status
make: *** [out/host/linux-x86/obj/EXECUTABLES/accRuntimeTest_intermediates/accRuntimeTest] Error 1
make: *** Waiting for unfinished jobs....
</code></pre>
| android | [4] |
4,698,491 | 4,698,492 | Python string list to string | <p>I am doing something painfuly simple, and rather than looping over the list, and += everything, I was wondering if there was a "sleezier" way to do it.</p>
<p>Simple concept I have something like:</p>
<pre><code>some_string_array = [ "s", "t", "a", "c", "k", " ", "o", "v", "e", "r", "f", "l", "o","w" ]
some_string = some_string_array.--sleezy built-in flatten--()
print(some_string)
</code></pre>
<p>And the result would be simply <code>stack overflow</code></p>
<p>I am sure it is painfuly simple, but I couldn't find a good way to search for this online.</p>
<p>Thanks.</p>
| python | [7] |
1,050,580 | 1,050,581 | how to unblockUI relative when the page finished loading or a "content" finished loading | <pre><code>$(document).ready(function() {
$('#storefront').click(function() {
$(".centerdiv").load("storefront_a.php");
$.blockUI({ css: {
border: 'none',
padding: '15px',
backgroundColor: '#000',
'-webkit-border-radius': '10px',
'-moz-border-radius': '10px',
opacity: .5,
color: '#fff'
} });
setTimeout($.unblockUI, 2000);
});
});
</code></pre>
<p>I got this code from <a href="http://jquery.malsup.com/block/#demos" rel="nofollow">Malsup</a> . It worked on any browsers except IE. The script simply generate a full screen "Please Wait" with interval of 2 seconds before it disappear. </p>
<p>"What I want is to only remove the "Please Wait" screen whenever a content or the page finshed loading. is it possible. Thanks for Helping me! I will appreciate every answers.</p>
| jquery | [5] |
5,498,349 | 5,498,350 | android- How to differentiate the Emulator and Device Programatically | <p>In My application one button is there. if you click on that button we are getting current Location. Based on this current Location i am doing some operations. In device it is working properly. But in emulator we are not getting the current Location thats why i am using the Some default Latitude and Longitude values for emulator. But i want to differentiate the emulator and device. It means we are running in the device means it takes the geocode locations. suppose we are running in the emulator means it takes the default latitude and longitude values. How to implement it pro-grammatically. can anybody help me.</p>
<p>thanks</p>
| android | [4] |
1,098,839 | 1,098,840 | want to edit emulator settings to charge emulator battery in android? | <p>Here i am attaching emulator screenshot ,please see battery in screenshot any one suggest me how to charge battery.</p>
<p>I tried this with telnet commands but emulator is not responding.</p>
<p><img src="http://i.stack.imgur.com/Y60HT.png" alt="emulator image"></p>
| android | [4] |
1,684,991 | 1,684,992 | How to create a datatable in one method, and reference it in another? | <p>c#/oop noob here. I am creating a datatable from the schema of a sql server database. I want to have a button that lets the user pick some tables out of this schema and do something (insert rows for example). However, the method is unable to reference the datatable of my first method - how can I reference the datatable made in the first method from another?</p>
<p>Here is the code I am using:</p>
<pre><code> public Form1()
{
/****************************************************************/
string sqlSchema = " SELECT TABLE_CATALOG AS tblname ";
sqlSchema += " , TABLE_SCHEMA AS tblschema ";
sqlSchema += " , TABLE_NAME AS tblname ";
sqlSchema += " , COLUMN_NAME AS colname ";
sqlSchema += " , DATA_TYPE AS DATA_TYPE ";
sqlSchema += " , CHARACTER_MAXIMUM_LENGTH AS colsize ";
sqlSchema += " FROM INFORMATION_SCHEMA.COLUMNS ";
InitializeComponent();
OleDbConnection cn = new OleDbConnection(@"Provider=SQLNCLI;Server=THINK\SQLExpress;Database=Northwind;Trusted_Connection=yes;");
OleDbDataAdapter da = new OleDbDataAdapter(sqlSchema, cn);
DataTable dt = new DataTable();
da.TableMappings.Add("Table","Schema");
da.Fill(dt);
dataGridView1.DataSource = dt;
}
public void sql_PopulateTable(string tablenm, int rows)
{
// error on this line:
DataTable table1 = da.Tables["Schema"];
}
</code></pre>
<p>The error I am getting is 'da' is not recognized in the current context. Should I be declaring my sqlSchema variable as static? How should I go about doing that syntactically?</p>
<p>Thanks --</p>
| c# | [0] |
3,560,640 | 3,560,641 | T_IF error in php registration form | <p>I am trying to get an php registration form working, but i am having problems with an if/else statement. but can't quite figure it out.</p>
<pre><code>ERROR: Parse error: syntax error, unexpected 'if' (T_IF) in E:\xampp\htdocs\test\register.php on line 21
</code></pre>
<p>PHP Code :</p>
<pre><code>$username = $_POST['username'];
$password = $_POST['password'];
$repassword = $_POST['repassword'];
$email = $_POST['email'];
if ($username && $password && $repassword && $email)
{
if ($password == $repassword)
{
include ("connect.php");
$query = mysql_query("SELECT * FROM users WHERE username = '$username'");
$numrows = mysql_num_rows($query)
if($numrows == 0) <<- LINE 21
{
echo "Username not taken";
}
else
{
echo "That username is taken!";
}
}
else
echo "Password did not match"; }
else
echo "You did not fill in every field!";
else {//show registration form Stackoverflow cant display it properly.}
</code></pre>
<p>Maby one of you guys sees the problem. </p>
<p>Thanxs in advance,</p>
<p>Jim</p>
| php | [2] |
3,944,646 | 3,944,647 | Store function result or call it each time? | <p>I have a class with a protected variable in it which can be get by a function <code>getVariable()</code>.</p>
<p>How much difference will it make if i'll call <code>getVariable()</code> every time instead of storing the result once and then use it? (the <code>getVariable()</code> does nothing more than <code>return $this->var</code>)</p>
| php | [2] |
1,344,843 | 1,344,844 | PHP's passthru() vs shell_exec() | <p>The function <code>passthru()</code> is good when the output contains binary data as the function outputs the raw output. However, the documentation for the function <code>shell_exec()</code> does not say whether the data returned is binary safe (=raw).</p>
<p>So, my question here is that does <code>shell_exec()</code> return the <strong>raw</strong> output? Or do I need to use <code>ob_start()</code>, <code>ob_get_contents()</code> and <code>ob_end_clean()</code> with <code>passthru()</code> to get the raw output?</p>
| php | [2] |
2,054,303 | 2,054,304 | Android : How do i use authToken to send email | <p>Somehow I managed to get AuthToken from Google in android but now I can't find that how could I use this token to send email using the email id and the authToken without user interaction
Please provide some example.</p>
| android | [4] |
3,164,351 | 3,164,352 | How to refresh gridview after every insert command automatically? | <p>I am inserting data to database when i click submit button data inserted into Database but no changes get reflected in GridView without refreshing the page.
I used DataBind() also.</p>
| asp.net | [9] |
5,217,794 | 5,217,795 | Start and stop div scrolling between two other divs | <p>Someone else recently helped me out with the start of this question but I'm after a little more help. I currently have this working - </p>
<pre><code>var windw = this;
$.fn.followTo = function ( elem ) {
var $this = this,
$window = $(windw),
$bumper = $(elem),
bumperPos = $bumper.offset().top,
thisHeight = $this.outerHeight(),
setPosition = function(){
if ($window.scrollTop() > (bumperPos - thisHeight)) {
$this.css({
position: 'absolute',
top: (bumperPos - thisHeight)
});
} else {
$this.css({
position: 'fixed',
top: 0
});
}
};
$window.resize(function()
{
bumperPos = pos.offset().top;
thisHeight = $this.outerHeight();
setPosition();
});
$window.scroll(setPosition);
setPosition();
};
$('#one').followTo('#two');
</code></pre>
<p>Example here - <a href="http://jsfiddle.net/Tgm6Y/1447/" rel="nofollow">jsFiddle</a></p>
<p>This stops a div from scrolling once it reaches the border of another div - works great. What I'm stuck trying to figure out now is how I can make the scrolling div START at a div, then scroll down and stop at another div as it does in this example. Anyone got any ideas? </p>
<p>Here's a terrible illustration of it - <a href="http://jsfiddle.net/Tgm6Y/1450/" rel="nofollow">jsFiddle</a>. The blue section SHOULD sit underneath the yellow section until you reach it. I just can't figure out how that's possible due to my limited brain function. </p>
<p>Thanks a lot for any help. </p>
| jquery | [5] |
5,827,732 | 5,827,733 | Looking for ways to shorten my code that text aligns an array | <p>just started learning java. This takes an array and lines the columns up, but it seems like there would be a way shorter way of coding this. I have no ideas though.. </p>
<pre><code> int longestString = 0;
int numberOfChars;
String information[][] = { {"First Name:", "a" },
{"Last Name:", "b"},
{"Nickname:", "c"},
{"Example:", "d"},
{"Example:", "e"},
{"Example:", "f"},
{"Example:", "g"}};
for(int i=0; i<information.length; i++){
if (information[i][0].length() > longestString) {
longestString = information[i][0].length();
}
}
numberOfChars = longestString + 1;
for(int i=0; i<information.length; i++){
while (information[i][0].length() < numberOfChars){
information[i][0] += " ";
}
}
for (int i=0; i<information.length; i++){
System.out.print(information[i][0]);
System.out.println(information[i][1]);
}
</code></pre>
| java | [1] |
5,502,763 | 5,502,764 | Killing children of children in python with subprocess | <p>Does python provide a way to find the children of a child process spawned using subprocess, so that I can kill them properly? If not, what is a good way of ensuring that the children of a child are killed?</p>
| python | [7] |
4,729,064 | 4,729,065 | Animation triggering for the .hide() part of slideToggle, but not the .show() part | <blockquote>
<p>When I use .slideToggle on an element, it doesn't display an animation
for the "show" event, but it does do an animation for the "hide" part of
the toggle.</p>
</blockquote>
<p>I hope this is not an idiotic question, but i've been searching around and I cannot find an answer. I am just learning Jquery, so forgive me if i've made a simple mistake. </p>
<p><a href="http://stackoverflow.com/questions/4359320/what-is-the-difference-between-toggle-and-slidetoggle-in-jquery">This</a> other post asks a similar question, but the definitions (slide toggle: animation toggle: no animation) don't seem to work.</p>
<p>Here's the J fiddle: </p>
<p><a href="http://jsfiddle.net/9jUNS/" rel="nofollow">http://jsfiddle.net/9jUNS/</a></p>
<p>Thanks for taking a look!
-Nick </p>
| jquery | [5] |
901,232 | 901,233 | C# : Looping forever foreach CheckedListBox item | <pre><code>foreach (CheckedListBox item in itemInfoCheckList.Items)
{
if (item.CheckState == CheckState.Checked)
SW.WriteLine(item.Text + " : YES");
else
SW.WriteLine(item.Text + " : NO");
}
</code></pre>
<p>THe above code snippet is where it loops ... although there are only 2 items
Below is the iteminfochecklist definition</p>
<pre><code> this.itemInfoCheckList.CheckOnClick = true;
this.itemInfoCheckList.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.itemInfoCheckList.FormattingEnabled = true;
this.itemInfoCheckList.Items.AddRange(new object[] {
"item 1 ",
"item 2"});
this.itemInfoCheckList.Location = new System.Drawing.Point(573, 350);
this.itemInfoCheckList.Name = "itemInfoCheckList";
this.itemInfoCheckList.Size = new System.Drawing.Size(197, 38);
this.itemInfoCheckList.TabIndex = 143;
</code></pre>
| c# | [0] |
4,331,512 | 4,331,513 | How to retrieve post vars sent by another page? | <p>I have a php page that opens and sends some variables to an external payment service (Sermepa). This page remains open while the payment process is active. When the payment process finishes it responds by sending a post request to a specified URL, without opening a browser window with the URL.</p>
<p>My question is: is it posible to catch the reponse post variables from this opened popup in the original window, to start another task as send stock or send invoice. Refreshing the original window is not possible, because I can not control the popup.</p>
| php | [2] |
382,891 | 382,892 | Are there some practical examples that use Object::* | <p>I just heard of that there is a kind of type like this,a point to Object member. Here is it </p>
<pre><code>class Point{float x, y;};
float Point::*p2 = &Point::x;
</code></pre>
<p>but I haven't use before,and wonder some-body really use it.Do you have any experience of that?</p>
| c++ | [6] |
4,525,695 | 4,525,696 | How to replace multiple occurences of a string in a text file with a variable entered by the user and save all to a new file? | <pre><code> public static void main(String args[])
{
try
{
File file = new File("input.txt");
BufferedReader reader = new BufferedReader(new FileReader(file));
String line = "000000", oldtext = "414141";
while((line = reader.readLine()) != null)
{
oldtext += line + "\r\n";
}
reader.close();
// replace a word in a file
//String newtext = oldtext.replaceAll("drink", "Love");
//To replace a line in a file
String newtext = oldtext.replaceAll("This is test string 20000", "blah blah blah");
FileWriter writer = new FileWriter("input.txt");
writer.write(newtext);writer.close();
}
catch (IOException ioe)
{
ioe.printStackTrace();
}
}
</code></pre>
<p>}</p>
| java | [1] |
604,233 | 604,234 | How to find N facorial using a For loop? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/5136447/function-for-factorial-in-python">Function for Factorial in Python</a> </p>
</blockquote>
<p>I need to write a program in python that returns N!, without using the factorial function. I have a program written so far but I keep getting an error saying, <code>local variable "fact" is assigned but never used</code>. How do I use <code>fact = 1</code>, after it is assigned?</p>
<pre><code>from pylab import *
def factorial(n):
fact = 1
for i in range(n):
print("i = ", i)
fact = fact * i
print("The factorial of " + str(n) + " is: " + str(fact))
</code></pre>
| python | [7] |
785,890 | 785,891 | How to send report via email monthly automatically in asp .net | <p>can any one send me solution on this problem . Here i want to send crystal report that is automatically generated and attach to mail . Here report can be generated monthly automatically with asp .net along with c# Lang. Send me solution for this.</p>
| asp.net | [9] |
5,440,882 | 5,440,883 | What is the simplest way to have one PHP script execute a different PHP script and assign the value it returns to a variable? | <p>I'm hitting a wall with this. It's difficult to find an answer because I'm not sure how to word the question, and I can't think of decent keywords either.</p>
<p>I'm writing a view object for use in an MVC framework I'm writing and it assembles pages by tying script outputs together. I'm stuck on the tie together part!</p>
<p>script1.php:</p>
<pre><code><?php
$variable = solution('/path/to/script2.php');
echo $variable;
?>
</code></pre>
<p>script2.php:</p>
<pre><code><?php
// generates a random md5 hash just for example
mt_srand(microtime(true)*100000 + memory_get_usage(true));
$randommd5 = md5(uniqid(mt_rand(), true));
echo $randommd5;
?>
</code></pre>
<p>How do I make both of these scripts return the same value every time I run script1.php?</p>
<p>Is there a PHP function for this purpose? If not, is there a simple and stable way of accomplishing this?</p>
| php | [2] |
3,883,584 | 3,883,585 | Dictionary transformation and counter | <p>Object:</p>
<pre><code>data = [{'key': 11, 'country': 'USA'},{'key': 21, 'country': 'Canada'},{'key': 12, 'country': 'USA'}]
</code></pre>
<p>the result should be:</p>
<pre><code>{'USA': {0: {'key':11}, 1: {'key': 12}}, 'Canada': {0: {'key':21}}}
</code></pre>
<p>I started experiment with:</p>
<pre><code>result = {}
for i in data:
k = 0
result[i['country']] = dict(k = dict(key=i['key']))
</code></pre>
<p>and I get:</p>
<pre><code> {'Canada': {'k': {'key': 21}}, 'USA': {'k': {'key': 12}}}
</code></pre>
<p>So how can I put the counter instead <code>k</code>? Maybe there is a more elegant way to create the dictionary?</p>
| python | [7] |
1,353,328 | 1,353,329 | How this code works to add the cache value? | <pre><code>public static void Add<T>(T cacheObject, string keyName)
{
HttpContext.Current.Cache.Insert(keyName, cacheObject, null, Cache.NoAbsoluteExpiration,
TimeSpan.FromMinutes(30));
}
</code></pre>
<p>Hello friends I am new to asp.net my question is I have this code to Add the cache value.</p>
<p>my question is when i cal this methods two times.. it will have two keys? or it will overwrite previous one?</p>
<p>thanks</p>
| asp.net | [9] |
1,025,811 | 1,025,812 | Is a control's OnInit called even when attaching it during parent's OnPreRender? | <p>My original understanding was that the asp.net page lifecycle is run once for all pages and controls under normal circumstances. When I attached a control during a container's OnPreRender, I encountered a situation where the control's OnInit was not called. OK, I considered that a bug in my code and fixed as such, by attaching the control earlier.</p>
<p>But just today, I encountered a situation where OnInit for a control seems to be called after the normal OnInit has been done for everyone else. See stack below. It seems that during the page's PreRender, the control's OnInit is called as it is being dynamically added.</p>
<p>So I just want to confirm exactly what ASP.NET's behavior is? Does it actually keep track of the stage of each control's lifecycle, and upon adding a new control, it will run from the very beginning?</p>
<p>[HttpException (0x80004005): The control collection cannot be modified during DataBind, Init, Load, PreRender or Unload phases.]
System.Web.UI.ControlCollection.Add(Control child) +8678663
MyCompany.Web.Controls.SetStartPageWrapper.Initialize()
MyCompany.Web.Controls.SetStartPageWrapper.OnInit(EventArgs e)
System.Web.UI.Control.InitRecursive(Control namingContainer) +333
System.Web.UI.Control.InitRecursive(Control namingContainer) +210
System.Web.UI.Control.AddedControl(Control control, Int32 index) +198
System.Web.UI.ControlCollection.Add(Control child) +80
MyCompany.Web.Controls.PageHeader.OnPreRender(EventArgs e) in
System.Web.UI.Control.PreRenderRecursiveInternal() +80
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +842</p>
| asp.net | [9] |
4,651,286 | 4,651,287 | How can i sell products through my android app (what are steps i have to follow) | <p>In my app i have several products to sell ,
if user clicks on any product it shows product details with pay button, how can i integrate paypal to that button,
i don't have good knowledge on integrating paypal please provide steps to do this.
thank you in advance.</p>
| android | [4] |
1,542,767 | 1,542,768 | Geolocation to Country Level | <p>I want to be able to determine just what country a person is in (on Android, without using the GPS), so I was thinking to use a web API, that I can call and it will return the country based on the request IP. But I can't find any web API that does this, does any exist?</p>
| android | [4] |
320,850 | 320,851 | PHP -> JavaScript | <p>Here is my PHP code..</p>
<pre><code>$input = "zergling-light"
$output = str_replace('-', ' (', $input).")";
$output = strtoupper(substr($input, 0, 1)).substr($input, 1);
echo $output;
// Prints.. Zergling (light)
</code></pre>
<p>..I'm extremely crappy with my JavaScript code, could someone help me convert this? I basically want to convert a variable such as "marine-heavy" to "Marine (heavy)".</p>
| javascript | [3] |
1,623,568 | 1,623,569 | "Comparison method violates its general contract!" | <p>Can someone explain me in simple terms, why does this code throw an exception, "Comparison method violates its general contract!", and how do I fix it?</p>
<pre><code>private int compareParents(Foo s1, Foo s2) {
if (s1.getParent() == s2) return -1;
if (s2.getParent() == s1) return 1;
return 0;
}
</code></pre>
| java | [1] |
437,958 | 437,959 | confused about compiling a basic java test program with package | <p>This is follow-up on my question:</p>
<p><a href="http://stackoverflow.com/questions/7593320/error-in-java-basic-test-program">error in java basic test program</a></p>
<p>This is still confusing me.
So specific problem is:</p>
<p>I already have a package and directory done.
say com.learn.java.mypackage</p>
<pre><code>$ pwd
.../com/learn/java/mypackage
</code></pre>
<p>and here I want to create a test program in the same package and execute it.</p>
<pre><code>$cat TestPackage.java
package com.learn.java.mypackage;
public class TestPackage
{
public static void main(String args[])
{
System.out.println("Hello World\n");
}
}
$ javac TestPackage.java
// runs file
$ Java TestPackage
Exception in thread "main" java.lang.NoClassDefFoundError: TestPackage (wrong name: com/learn/java/TestPackage)
</code></pre>
<p>if java runtime wants to make sure that a file belonging to a package lives in the same named directory, it is true here. Then why does it still crib?</p>
| java | [1] |
2,381,463 | 2,381,464 | how to implement search box in my application in android? | <p>i have one activity in my android application in which a list of orders is populated. I want to implement a search functionality on this activity so that user can search for particular order. </p>
<p>I have read about the search box facility provided by adding a <code>searchable.xml</code> file in the application but I am not able to make it work for me?</p>
<p>I just want to add a search box in the activity and search for specific data in database.
How can I do this?</p>
| android | [4] |
2,347,539 | 2,347,540 | PHP caching class | <p>I'm a AS3 coder and i do a bit of php and i am having a hard time doing a static class that can cache variables.</p>
<p>Here's what i have so far :</p>
<pre><code><?php
class Cache {
private static $obj;
public static function getInstance() {
if (is_null(self::$obj)){
$obj = new stdClass();
}
if (!self::$instance instanceof self) {
self::$instance = new self;
}
return self::$instance;
}
public static function set($key,$value){
self::$obj->$key = $value;
}
public static function get($key){
return self::$obj->$key;
}
}
?>
</code></pre>
<p>And i use the following to set my variable into an object of my static class :</p>
<pre><code><?php
include 'cache.php';
$cache = new Cache();
$cache->set("foo", "bar");
?>
</code></pre>
<p>And this is retrieve the variable</p>
<pre><code> <?php
include 'cache.php';
$cache = new Cache();
$echo = $cache->get("foo");
echo $echo //doesn't echo anything
?>
</code></pre>
<p>What am i doing wrong ? Thank you</p>
| php | [2] |
4,763,121 | 4,763,122 | How to display the contents of a directory | <p>I need to write a recursive algorithm to display the contents of a directory in a computer's file system but I am very new to Java. Does anyone have any code or a good tutorial on how to access a directory in a file system with Java??</p>
| java | [1] |
359,810 | 359,811 | How can I avoid rewriting construction logic present in initializer lists? | <p>Suppose I have a CPP class like</p>
<pre><code> class A {
A() :
max_(0),
num_(0),
sum_(0),
sum_squares_(0) {}
void Clear() {
min_ = bucketMapper.LastValue();
max_ = 0;
num_ = 0;
sum_ = 0;
sum_squares_ = 0;
}
void SomethingElse {}
}
</code></pre>
<p>I have the initialization code in the constructor and in Clear, is there a way I can avoid having the same code twice.</p>
| c++ | [6] |
2,176,234 | 2,176,235 | FedEx Label image on pdf document | <p>I have a fedex shipping label obtained using FedEx API with php. I am using FPDF library to create a pdf document. I need to add the FedEx shipping label image in that document. The image has been generated with 4x6 (800 x 1200 pixels) inches dimensions and with 200 dpi and they say that we need to convert it into 96 dpi by setting it's width and height to 384 and 576. I used these width and height as:</p>
<pre><code>$pdf->Image('label.png',0, 70, 384, 576)
</code></pre>
<p>But it's not working and image is not adjusted on the document. Am I interpreting this wrong or is there something that I have skipped. Please help.</p>
| php | [2] |
809,129 | 809,130 | get file where class has been declared/required from | <p>how is it possible to get the file and line where a class has been declared from and/or required?</p>
| php | [2] |
3,095,050 | 3,095,051 | i want to draw circle around my current location and find out other users which are come in range of this circle on my google map in android | <p>in this my gps application i want to draw circle around my current location i did it ...but now i find out other users which are come in cirle range so i want popoup in my application screen so can anyboby help me...</p>
| android | [4] |
3,630,529 | 3,630,530 | Hide a div using jQuery when | <p>I have a list of items, each of which needs to show a div. Click on one, and it shows you a div with tweets in it. I've been able to successfully show the divs with jQuery. Unfortunately, I have no clue how to hide the divs when the user clicks outside of said div. I've tried fiddling around with the .not() selector, but I just can't do it. Here's my code:</p>
<pre><code>$("#twitter-wid").click(function() {
$(".recent_tweets").fadeIn(400);
});
</code></pre>
<p>In this case, #twitter-wid is the 'li' item, and .recent_tweets is the div element that I need to show. I want it such that when the user clicks anywhere out of .recent_tweets that it should hide. I've so far tried to add:</p>
<pre><code>$.not('.recent_tweets').click(function() {
$('.recent_tweets').hide();
});
</code></pre>
<p>But to no avail. Oh and I'm new to jQuery. Thanks!</p>
<p>EDIT: I wonder how Twitter does it for their little drop-down menu. Click on your username and it drops down a bunch of options. Click anywhere out and it slides up.</p>
| jquery | [5] |
1,613,791 | 1,613,792 | How to get Uri of res folder? | <p>I am trying to get the Uri of an image I have in the drawable folder. I tried many possible ways but nothing seems to work. Can anyone suggest me how to get the Uri of res folder. Any help is much appreciated. </p>
| android | [4] |
1,693,702 | 1,693,703 | Stuck with date compare in php | <pre><code><?php
date_default_timezone_set('America/Los_Angeles');
$urlYear = '2013';
$currentYear = date('Y');
$systemDate = date('d-m-Y');
if ( ($systemDate >= '01-06-'.$currentYear) || ($currentYear < $urlYear) ) {
echo 'Here are your results <br>';
echo 'System Date '.$systemDate.' '.$currentYear.' '.$urlYear;
} else {
echo 'No results for you';
}
?>
</code></pre>
<p>What I'm trying to achieve is:</p>
<pre><code>(If the current date as formatted by me is >= '01-06'-year of the current year)
OR
(if the $currentYear < $urlYear)
//echo 'Here are your results';
</code></pre>
<p>But I seem to be getting true for everything. Can you pls help?</p>
| php | [2] |
4,066,481 | 4,066,482 | C# reading and writing from & to same file | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/605685/how-to-both-read-write-file-in-c-sharp">How to both Read/Write File in C#</a> </p>
</blockquote>
<p>I want to write and read text to and from the same text file. Here is the code </p>
<pre><code>TextWriter notesWriter = new StreamWriter("text.txt");
TextReader notesReader; = new StreamReader("text.txt");
</code></pre>
<p>Once the file is open for writing it is being locked and prevents to read from it.
So, some exception is thrown like,</p>
<blockquote>
<p><em>The process cannot access the file 'text.txt' because it is being used by another process.</em></p>
</blockquote>
<p>what is the workaround for this ? thank you.</p>
<p>EDIT:
Suppose, if want to change text in a textbox and save it in a file and read from it when required to set the text in the textbox.</p>
| c# | [0] |
3,689,764 | 3,689,765 | String Comparison in Java...? | <p>why first comparison ( s1 == s2 ) displays equal whereas 2nd comparison ( s1 == s3 ) displays not equal....?</p>
<pre><code> public class StringComparison
{
public static void main( String [] args)
{
String s1 = "Arsalan";
String s2 = "Arsalan";
String s3 = new String ("Arsalan");
if ( s1 == s2 )
System.out.println (" S1 and S2 Both are equal...");
else
System.out.println ("S1 and S2 not equal");
if ( s1 == s3 )
System.out.println (" S1 and S3 Both are equal...");
else
System.out.println (" S1 and S3 are not equal");
}
}
</code></pre>
| java | [1] |
2,492,690 | 2,492,691 | Calling char method into main method | <p>How do I call this method into my main method: </p>
<pre><code> public static char shiftLetter(char aLetter, int offset){
if((aLetter >= 65 && aLetter <= 90) || (aLetter >=97 && aLetter <=122)){
char shifted = (char) (aLetter + offset);
return shifted;
}else{
return aLetter;
}
}
</code></pre>
<p>Here is my main method:</p>
<pre><code> public static void main(String[]args){
Scanner in = new Scanner (System.in);
String isAnswer = askQ();
if (isAnswer.equals("encode") || isAnswer.equals("decode")){
String text = isText();
int offset = isOffset();
char[] myString = text.toCharArray();
System.out.println(myString);
</code></pre>
| java | [1] |
2,989,864 | 2,989,865 | Develop an android application to manipulate the data of remote server? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/7681510/best-way-to-load-external-data-in-android">Best way to load external data in android</a> </p>
</blockquote>
<p>I want to develop an Android application to manipulate data on remote servers, but I don't know where to start. I have these questions:</p>
<ol>
<li><p>Is it possible to manipulate data on the remote servers....?</p></li>
<li><p>If so, Which technology I should use?</p></li>
<li><p>can Anybody provide me sample source codes</p></li>
</ol>
<p>Any help will be appreciated.</p>
| android | [4] |
5,798,032 | 5,798,033 | how to play song in my php web site when click on play link | <p>I need to play song in my php web site, when click on the play button.
but i don't know how implement this? Please advise.. Also which one is the best song file type to upload via input type file method . Is Mp3 ?
Please reply</p>
| php | [2] |
5,748,945 | 5,748,946 | the jquery script refresh back after it excecutes | <pre><code><script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$(".comment").click(function(){
$(".commentForm").slideToggle("slow");
});
});
</script>
</head>
</code></pre>
<p>this script above will slide in a from but then somehow the browser refresh again and bring it back to original mode where user can see the form instead of staying with the form hided or slided in. </p>
<p>I have tried in two browser Chrome and Mozzilla in Chrome the refresh back is faster than firefox.</p>
<p>why is that happening is the jquery.js causing this ?</p>
| jquery | [5] |
3,989,390 | 3,989,391 | DataRow conversion issue in asp.net | <p>How to convert system.data.datarow to an integer?</p>
<p>I Have a datarow which is returning the count of records which i want to store in an integer variable
The statement is as follows</p>
<pre><code>int TotalRecords=ds.Tables[1].Rows[0];
</code></pre>
<p>here ds is the DataSet.</p>
<p>when i am trying to write the above statement it is telling me that i cannot implicitly convert System.Data.DataRow to int</p>
| asp.net | [9] |
110,103 | 110,104 | assigning value to a textfeild in Android application? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/4590957/how-to-set-text-in-an-edittext">How To Set Text In An EditText</a> </p>
</blockquote>
<p>how can we assign value to a textfeild in android application?</p>
| android | [4] |
5,109,172 | 5,109,173 | is it possible to replace images in an array dynamically | <p>hi i am new to iphone.what i am need is to place a 20 images names in an array . if i place those images in an array whether it is possible or not to change replace the first image by last means changing the positions of images dynamically if it is not possible pls suggest in what way i can done this. pls post any sample code thank u </p>
| iphone | [8] |
2,947,176 | 2,947,177 | C++ setting reference variable in a class and afterwards changing | <p>Say I have a class Foo with a reference variable of type Bar and a constructor like so: </p>
<p>Foo.h: </p>
<pre><code>class Foo {
public:
Bar& m_b;
Foo(Bar& b);
}
</code></pre>
<p>Foo.cpp</p>
<pre><code>Foo::Foo(Bar& b) : m_b(b) {
}
</code></pre>
<p>And in a separate class I have:</p>
<pre><code>// global
Bar b;
Foo f(b);
int main() {
b.setData(); // actually set some values...
f.m_b.showData(); // will it show the change?
return 0;
}
</code></pre>
<p>Will the reference variable in f also have that change of data after setData() is called? I am trying this work-around because I have a class that has a reference variable (which must be set during initialization) but I need it to be globally accessible (declared before actually setting the data in Bar).</p>
| c++ | [6] |
3,882,619 | 3,882,620 | How to make Slide show for Apple iphone | <p>HI anyone Please let me know i need to Make a Slide show Application which can have 10 images and i need to keep all these Images in a Slide show manner </p>
| iphone | [8] |
5,765,746 | 5,765,747 | Using a variable as part of a variable name | <p>I have object1 which has many sub-objects in it. These sub-objects are accessed in the form <code>object1.subobject</code>. I have a function which returns a list of sub-objects of the original object. All I would like to do is iterate through the list and access each sub-object. Something like this: </p>
<pre><code>temp_list = listSubChildren(object1) #Get list of sub-objects
for sub_object in temp_list: #Iterate through list of sub-objects
blah = object1.sub-object #This is where I need help
#Do something with blah #So that I can access and use blah
</code></pre>
<p>I looked at similar questions where people used <code>dictionaries</code> and <code>getattr</code> but couldn't get either of those methods to work for this.</p>
| python | [7] |
4,068,290 | 4,068,291 | Getting extra data from server along with POST request | <p>So I've got some pagination working, but there's a variable I need access to (total pages). When I get the data to display in the table from changing the page (or otherwise updating the table), what's a good way to get the variable in the same request?</p>
| jquery | [5] |
2,359,488 | 2,359,489 | Android library project - how to get context? | <p>I have been happily refactoring code from different versions of the same app (paid/free) into Android library projects so that the actual apps can simply customize the library and reduce code duplication.</p>
<p>One thing I'm started to wonder is what getApplicationContext() inside the library code means? Is is the same ApplicationContext as one would get from the child apps? What happens when I access SharedPreferences from a library project's getApplicationContext() instead of the original app's ApplicationContext()? Will the SharedPreferences file be same or different?</p>
<p>What if I had used the activity to access SharedPreferences? Does it matter that the activity is now a library activity and not the original app? Is the SharedPreferences the same?</p>
<p>Thanks for clarifying.</p>
| android | [4] |
3,843,949 | 3,843,950 | android: Flurry Ads Banner taking Full screen | <p>I am implementing flurry banner ads in my app. But it takes full screen.
My main activity.xml is</p>
<pre><code><?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background"
android:orientation="vertical" >
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/bannerframe" >
</FrameLayout>
<SeekBar
android:id="@+id/volumeBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp" />
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</code></pre>
<p>and in java i am doing this code.</p>
<pre><code>FrameLayout fViewGroup = (FrameLayout)findViewById(R.id.bannerframe);
FlurryAgent.onStartSession(appContext, "My API Key is here");
FlurryAgent.initializeAds(appContext);
FlurryAgent.getAd(appContext, "Deer Hunting Calls",fViewGroup,FlurryAdSize.BANNER_TOP, 0);
</code></pre>
<p>following is the screen shot i am getting.
<img src="http://i.stack.imgur.com/L6B7g.png" alt="enter image description here"></p>
<p>anyone know why add is getting full screen???
I have tried all options in android:layout_width and height with fill_parent, warp_content, match_parent etc. but still get the same results. </p>
| android | [4] |
2,646,150 | 2,646,151 | how to round up to the next x20 number with php? | <p>I know ceil, which will round 15.1 to 16 and 31.2 to 32.
But how to round up to the next x20 number? like 15.1 to 20 and 31,2 to 40?</p>
<p>Is needed to make sensefull labels for the y-axis of a chart.</p>
| php | [2] |
3,290,374 | 3,290,375 | every element of list is True boolean | <p>I know that</p>
<pre><code>all(map(compare,new_subjects.values()))==True
</code></pre>
<p>would tell me if every element of the list is True. However, how do I tell whether every element except for one of them is True?</p>
| python | [7] |
191,485 | 191,486 | can i use throw function on android | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/3217925/enable-exception-c">Enable Exception C++</a> </p>
</blockquote>
<p>when i use throw function ,like as follow:</p>
<pre><code>throw "SobelGradient => cannot allocate memory";
</code></pre>
<p>this error come out: exception handling disabled, use -fexceptions to enable</p>
<p>And how to solve this error.</p>
| android | [4] |
4,358,315 | 4,358,316 | Swap value of two properties on object(s) | <p>I'm trying to make a simple function that will swap the values of two properties on the same or different global objects. </p>
<pre><code>object1 = {"key 1":"value 1"};
object2 = {"key 2":"value 2"};
swapValuesInObject ("object1['key 1']","object2['key 2']",true)
// should result in:
// object1 === {"key 1":"value 2"};
// object2 === {"key 2":"value 1"};
</code></pre>
<p>Another example:</p>
<pre><code>object1 = {"key 1":"value 1", "key 2":"value 2"};
swapValuesInObject ("object1['key 1']","object1['key 2']",1===1)
// should result in:
// object1 === {"key 1":"value 2", "key 2":"value 1"};
</code></pre>
<p>Here's what I've been able to come up with so far, but it's not much. Getting hung up on how to do the assignment.</p>
<pre><code>function swapValuesInObject(property1, property2, condition) {
if (condition) {
// temp assignment
var Obj1Value = property1;
// do the switcheroo
array1 = array2Value;
array2 = array1Value;
}
return true;
};
</code></pre>
<p>What's the proper way to do this?</p>
| javascript | [3] |
310,870 | 310,871 | multiple controls in UIView using IB | <p>How can I create multiple controls (such as UISwitch) in a UIView (or on top of UIScrollView) using the interface builder? I have about 20 such controls.</p>
<p>Appreciate any pointers.</p>
| iphone | [8] |
2,279,366 | 2,279,367 | Send data to server URL and read back responses | <p>I have a program that I have a text file full of raw data which I would like to send to a server. I have the URL of the server, and an Array which I have all the responses I need to send. I would like to send the responses then echo back what the server receives into a text box just to double check what's being sent is correct. Can anyone help point me in the right direction of how to approach my problem.</p>
| c# | [0] |
4,081,672 | 4,081,673 | encapsulating javascript inside a namespace | <p>I'm looking to encapsulate my javascript inside a namespace like this:</p>
<pre><code>MySpace = {
SomeGlobal : 1,
A: function () { ... },
B: function () { ....; MySpace.A(); .... },
C: function () { MySpace.SomeGlobal = 2;.... }
}
</code></pre>
<p>Now imagine that instead of a few lines of code, I have about 12K lines of javascript with hundreds of functions and about 60 globals. I already know how to convert my code into a namespace but I'm wondering if there's a quicker way of doing it than going down 12K lines of code and adding <code>MySpace.</code> all over the place.</p>
<p>Please let me know if there's a faster way of doing this.
Thanks for your suggestions.</p>
| javascript | [3] |
5,408,974 | 5,408,975 | Get the number from the element's id | <p>I have some inputs as below:</p>
<pre><code><input type="hidden" id="selected_id-1" name="id[]" />
<input type="hidden" id="selected_id-2" name="id[]" />
<input type="hidden" id="selected_id-3" name="id[]" />
<input type="hidden" id="selected_id-5" name="id[]" />
</code></pre>
<p>The list can contain more than just 4 elements.</p>
<p>So, I would like to extract the highest number (in our case = 5) from the ids of elements named "id".</p>
<p>Pure JavaScript needed.</p>
<p><strong>EDIT:</strong> Thank you everybody who answered my question.</p>
| javascript | [3] |
2,685,641 | 2,685,642 | How to create a dynamic ASP:ImageMap | <p>I want to create an ASP:ImageMap with a dynamic number of hot spots. I tried the code below, but it complains about having a repeater nested inside an image map. Any ideas on how to do this?</p>
<pre><code> <asp:ImageMap ID="imgMap" runat="server" ImageUrl="~/circles.png"
HotSpotMode="PostBack">
<asp:Repeater runat="server" id="repeat" DataSource=<%#circles %>>
<asp:CircleHotSpot PostBackValue="<%#name %>"
Radius="<%#r %>"
X="<%#x %>"
Y="<%#y %>" />
</asp:Repeater>
</asp:ImageMap>
</code></pre>
<p>(Please ignore problems with databinding. I'll solve those later.)</p>
| asp.net | [9] |
3,546,070 | 3,546,071 | Java program execution | <p>Please explain me how this program is behaving?</p>
<pre><code>class A
{
//public static String name = "asdf";
public static final String name = "asdf";
static {
System.out.println("static block inside A");
}
{
System.out.println("regular code block");
}
}
public class tt
{
public static void main(String ar[])
{
System.out.println(A.name);
//A a = new A();
}
}
</code></pre>
<ol>
<li><p>While executing the above program, i got the output as - <strong>asdf</strong><br>
Qns : Why none of the code blocks are not getting executed?</p></li>
<li><p>If i uncomment the non final static variable name and
comment the final static variable, i got the output as - <strong>static block inside A</strong><br>
<strong>asdf</strong>
<br>Qns : Why the regular code block is not getting executed? </p></li>
<li><p>If i comment the System.out.println(A.name); and
uncomment the A a = new A(); in class tt
i got the output as - <strong>static block inside A</strong><br>
<strong>regular code block</strong><br><br>
Qns: Here both blocks are getting executed.
But what is the difference between static block and
regular block?</p></li>
</ol>
| java | [1] |
1,385,307 | 1,385,308 | How to select images from a folder in a directory? | <p>am using a slideshow similar to <a href="http://tympanus.net/codrops/2010/05/23/fresh-sliding-thumbnails-gallery-with-jquery-php" rel="nofollow">http://tympanus.net/codrops/2010/05/23/fresh-sliding-thumbnails-gallery-with-jquery-php</a>, i want each image of a folder to be displayed instead of drop down as am trying to learn PHP.....Please help</p>
| php | [2] |
4,207,039 | 4,207,040 | Handling map of files in c++ | <p>I need to write to a bunch of files simultaneously, so I decided to use <code>map <string, ofstream></code>.</p>
<pre><code>map<string, ofstream> MyFileMap;
</code></pre>
<p>I take a <code>vector<string> FileInd</code>, which consists of, say <code>"a" "b" "c"</code>, and try to open my files with:</p>
<pre><code>for (vector<string>::iterator it = FileInd.begin(); iter != FileInd.end(); ++it){
...
MyFileMap[*it].open("/myhomefolder/"+(*it)+".");
}
</code></pre>
<p>I get the error</p>
<pre><code>request for member 'open' in ..... , which is of non-class type 'std::ofstream*'
</code></pre>
<p>I've tried to switch to </p>
<pre><code>map<string, ofstream*> MyFileMap;
</code></pre>
<p>But it didn't work either.</p>
<p>Could anyone help?</p>
<p>Thanks.</p>
<p><strong>Clarification:</strong></p>
<p>I've tried both </p>
<p><code>map<string, ofstream> MyFileMap;</code>
<code>map<string, ofstream*> MyFileMap;</code> </p>
<p>with both</p>
<p><code>.open</code>
<code>->open</code></p>
<p>neither of 4 variants work.</p>
<p><strong>Solution (suggested in Rob's code below):</strong></p>
<p>Basically, I forgot "new", the following works for me:</p>
<pre><code>map<string, ofstream*> MyFileMap;
MyFileMap[*it] = new ofstream("/myhomefolder/"+(*it)+".");
</code></pre>
| c++ | [6] |
2,218,952 | 2,218,953 | How to catch or receive android os ' broadcasts' of installed applications? | <p>I want to receive broadcasts of android installed applications. What would be the procedure ?</p>
| android | [4] |
2,234,974 | 2,234,975 | In C++, how do I correctly load a file into an array of wider than char data types? | <p>Specifically, I'm trying to program an FPGA with a binary file. The transaction register is 16-bits wide. So I need to create an array of uint16_t and fill it with an input file. Here is what I tried:</p>
<pre><code>int bufferSize = 512;
uint16_t buffer[bufferSize];
std::ifstream *pStream = new std::ifstream( filepath );
if( pStream->is_open() == true )
{
pStream->read( (char *)buffer, bufferSize );
}
</code></pre>
<p>From what I can tell through GDB, it seems each array node is backwards (ie. expected 0xBEEF, got 0xEFBE)</p>
| c++ | [6] |
809,590 | 809,591 | Terminate android app | <p>I have an app with an intro screen, there will be two buttons in this screen (Ok and Cancel)</p>
<p>If the user clicks the cancel button the application will terminate, and if the user clicks the ok button ,the main screen appears, the main screen got a back button to go back to the intro screen.</p>
<p>Now, my problem is I have used </p>
<pre><code>finish();
</code></pre>
<p>for the cancel button, and what I understood is that the '<code>finish()</code>' will terminate the current running activity.</p>
<p>Once the application is started and if the user clicks the cancel button, the app terminates, but if the user goes to the main screen and comes back to the intro screen and then click cancel the intro screen will exit(Activity responsible for the intro screen).and the main screen appears back.</p>
<p>This forms a continuous loop since the previous Activity (activity opened just before the intro activity) will always appear even if the user clicks the cancel button...</p>
<p>Does anyone have an idea how to terminate more than one activity at a time?</p>
| android | [4] |
3,205,799 | 3,205,800 | Function-pointer syntax ambiguity | <p>Take the following example. I create a function pointer named <code>s</code>, set it to <code>f</code> and call it. This compiles fine of course:</p>
<pre><code>void f() {}
int main() {
void (*s)();
s = f;
s();
}
</code></pre>
<p>But take this next example, where I declare <code>s</code> now as a "function reference" (if it's so called) and set to <code>f</code> inline. This compiles fine as well:</p>
<pre><code>void f() {}
int main() {
void (&s)() = f;
s();
}
</code></pre>
<p>What are the differences between these two ways to create and initialize a function-pointer? Note that when I use the reference syntax I am required to initialize it "in-line" to <code>f</code> whereas with the "pointer" syntax I had the ability to do it both ways. Can you explain that as well? And with that, can you explain what their differences are in terms of usability, and when must I use one form over the other?</p>
| c++ | [6] |
2,970,904 | 2,970,905 | Creating Js object with Object.create(null)? | <p>I know a lot of ways to create JS objects but I didn't know the <code>Object.create(null)</code> one.</p>
<p>and so : is it exactly the same as</p>
<p><code>var p={}</code> ? </p>
<p>vs</p>
<p><code>var p2=Object.create(null);</code></p>
<p>?</p>
| javascript | [3] |
5,270,039 | 5,270,040 | PHP Variables Link/Display | <p>I'm passing variables from my Flash MP3 player to a PHP script to record what songs have played. Now I want the PHP script to display one varable and include it in an Amazon link.</p>
<p>This is what I have but can't seem to get it to work.</p>
<pre><code><?php
$var1 = $_POST['var1']; //get the Artist Name and Title from Flash and store it in a PHP variable
$var2 = $_POST['var2']; //ignored
//This lines combines the two variables into one string.
//To concatinate vars in PHP use a period or dot ".", much like Flash uses a plus sign "+".
$add = $var1 . "+" . $var2 . "|";
//opens or creates (if it doesn't already exist) our text file (songsplayed.txt)
//for writing (not reading) and places the pointer at the end.
$open = fopen('songsplayed.txt', 'a');
//writes to our specified file our string
$write = fwrite($open, $add);
echo $var1;
echo
<a type="amzn" search=\"$var1\" category="music">
<img border="0" src="/buttons/buy-now-button-amazon.png" alt="Buy now @ Amazon"></a>
?>
</code></pre>
| php | [2] |
3,842,527 | 3,842,528 | Java casting resulting in run-time error instead of compilation error | <p>The following code snippet will result in a run-time:</p>
<pre><code>class Vehicle {
public void printSound() {
System.out.print("vehicle");
}
}
class Car extends Vehicle {
public void printSound() {
System.out.print("car");
}
}
class Bike extends Vehicle {
public void printSound() {
System.out.print("bike");
}
}
public class Test {
public static void main(String[] args) {
Vehicle v = new Car();
Bike b = (Bike) v;
v.printSound();
b.printSound();
}
}
</code></pre>
<p>My question is: why does that result in a run-time error but not a compilation error? Shouldn't the compiler know that 'v' is already a 'Car' and cannot be cast into a 'Bike'?</p>
| java | [1] |
4,618,019 | 4,618,020 | Issue with for loop of checkboxes | <p>I have series of checkboxes whom value I am taking and generating a string like....if checkbox is selected I add '1' to string and if it is not selected I add '0' to string. </p>
<pre><code><input type="checkbox" name="auth_0" id="auth_0" class="checkboxes" value="Yes"/>
</code></pre>
<p>My php script is...</p>
<pre><code>if (isset($_REQUEST["save"])) {
/* echo $_REQUEST['auth_0'];*/
for ($i = 0; $i <= 49; $i++) {
if ($_REQUEST['auth_[$i]'] == 'Yes') {
$auth_string .= '1';
} else {
$auth_string .= '0';
}
}
echo $auth_string;
}
</code></pre>
<p>Though string is generating but its value is always 0 in both cases that if checkbox is selected or not.</p>
| php | [2] |
4,784,682 | 4,784,683 | Directly add Clip icon to Home Screen of an iphone when webapp is first accessed | <p>I want to know that is there any way that I can add my webapp's clip icon to the Homescreen of an iPhone directly when user first acessess my webpage through the Safari ?</p>
| iphone | [8] |
5,817,220 | 5,817,221 | Java Final - an enduring mystery | <pre><code>suggestBox.addKeyUpHandler( new KeyUpHandler() {
public void onKeyUp(KeyUpEvent event) {
if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
String boxText = suggestBox.getText();
if (!boxText.equals("")) {
suggestPanel.add(checkBoxFactory(boxText, candidateNames));
suggestBox.setText("");
}
}
}
});
</code></pre>
<p>I havent been able to grasp why java forces me to declare the ArrayList (candiateNames) as final? why is this?</p>
| java | [1] |
5,434,007 | 5,434,008 | How to get elements where data-ZZZ is not blank | <p>I've got html that looks something like:</p>
<pre><code><div id="1" class="lineItem" data-options="">Line1</div>
<div id="2" class="lineItem" data-options="{size: M;}">Line2</div>
<div id="3" class="lineItem" data-options="{color: black;}">Line3</div>
</code></pre>
<p>Can I construct some sort of selector to just get <code><div id="2"></code> and <code><div id="3"></code>?</p>
<p>Something like:</p>
<pre><code>$('.lineItem[data-options='not blank']')
</code></pre>
<p>Is this possible, or do I have to go through each of the DIVs manually to check that the data-options attribute isn't blank?</p>
| jquery | [5] |
4,449,170 | 4,449,171 | its it possible to have two ELSEIF clauses in a IF ternary? | <p>can this be made into an IF ternary to shorten the code? I don't know how to do it with multiple elseif clause</p>
<pre><code>if ($ext == "m") {
$extype = "mp3";
}elseif ($ext == "w") {
$extype = "wav";
}elseif ($ext == "a"){
$extype = "aac";
}
</code></pre>
<p>the is the full function </p>
<pre><code>function loc($id,$type,$ext) //loc($id,'n',$ext)
{
if (($query = mysql_query("SELECT loc FROM names WHERE id = '".(int)$id."'")) !== false)
{
if (mysql_num_rows($query) > 0)
if ($ext == "m") {
$extype = ".mp3";
}elseif ($ext == "w") {
$extype = ".wav";
}elseif ($ext == "a") {
$extype = ".aac";
}
return '/rec/'.mysql_result($query,0,'loc').$id.'-'.($type=='n'?'n':'s').$extype);
}
return 'Error Not Found';
}
</code></pre>
| php | [2] |
2,399,182 | 2,399,183 | Convert HTML to PDF in ASP.NET | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/564650/convert-html-to-pdf-in-net">Convert HTML to PDF in .NET</a> </p>
</blockquote>
<p>How can i use the acrobat driver to covert web page to pdf , i have a icon on my browser. How can i use that in ASP.NET to convert the web page to pdf pro grammatically.</p>
| asp.net | [9] |
5,255,263 | 5,255,264 | How to create torrent files using javascript | <p>I want to create torrent files with a Firefox extension written using javascript.
Torrent file creators are currently available as desktop applications in anything but javascript.
May be it is also possible to find a decent torrent file spec in java, as azurious, an open source p2p client, is written in java.
Can somebody please give me hints, or maybe some specs, to achieve it using javascript.</p>
| javascript | [3] |
5,460,683 | 5,460,684 | Generate PDF when clicking on a link | <p>MY PROBLEM STATEMENT IS,</p>
<p>I have a set of links in a webpage,which was created in javascript.</p>
<p>Now what I want is if anybody clicks the link it should go to that
corresponding page and a pdf file should generate automatically. In
Ubuntu OS there is an option to generate PDF of any page, but how would I use it
to generate automatically, if need with some condition also.</p>
| javascript | [3] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.