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 |
|---|---|---|---|---|---|
311,430 | 311,431 | Output from this array | <pre><code>array(2) {
[0]=>
array(4) {
["id"]=>
string(1) "1"
["name"]=>
string(3) "Lim"
["subproject_id"]=>
string(1) "5"
["subproject_name"]=>
string(4) "Mads"
}
[1]=>
array(1) {
[0]=>
array(4) {
["id"]=>
string(1) "1"
["name"]=>
string(3) "Lim"
["subproject_id"]=>
string(1) "4"
["subproject_name"]=>
string(5) "KANYE"
}
}
}
</code></pre>
<p>How can I output each <code>name</code> and <code>subproject_name</code>?</p>
<p>A simple <code>foreach()</code> will only get the first one.</p>
| php | [2] |
5,533,115 | 5,533,116 | Can an activity receive an unordered broadcast(incoming call) intent before system's default receiver? | <p>Here is the scenario :</p>
<p>An activity is displayed(active). If a phone call comes, the activity should receive the intent (send the "incoming call screen" to the background/hide it from the display) and itself remain visible to the user. I dont necessarily want to suppress the incoming phone call as I have read in a lot of questions that it is not possible with public APIs.</p>
<p>All I want is to somehow make that android's default incoming call screen hidden by my activity on the top. </p>
<p>This behavior is only required when my activity is visible which is NOT EQUAL TO having a PHONE_STATE broadcast receiver to start my activity. The latter question has been answered a number of times on SO.</p>
<p>Please help me. I have been looking for directions for almost a day now.</p>
<p>Thanks for your time.</p>
| android | [4] |
4,801,959 | 4,801,960 | What's wrong with my string reversal function? (C#) | <pre><code>char[] a = { 'o', 'r', 'a', 'n', 'g', 'e' };
for (int i = 0; i < a.Length/2; i++)
{
a[i] = (char)(((uint)a[i])|((uint)a[a.Length-(i+1)]));
a[a.Length-(i+1)] = (char)(((uint)a[i])^((uint)a[a.Length-(i+1)]));
a[i] = (char)(((uint)a[i])^((uint)a[a.Length-(i+1)]));
}
</code></pre>
<p>I know how to implement this using standard .NET functionality and temp vars. I am just curious what specifically I am doing wrong in the above example that causes it not to work when the following works fine:</p>
<pre><code>int a = 5;
int b = 10;
a = a | b;
b = a ^ b;
a = a ^ b;
</code></pre>
<p>Isn't the above string version just a series of those?</p>
| c# | [0] |
2,704,599 | 2,704,600 | jQuery accordion expanded | <p>I am trying to create an accordion with jQuery from this example </p>
<p><a href="http://docs.jquery.com/UI/Accordion" rel="nofollow">http://docs.jquery.com/UI/Accordion</a></p>
<p>The markup is the same, i.e.</p>
<pre><code><div id="accordion">
<h3><a href="#">First header</a></h3>
<div>First content</div>
<h3><a href="#">Second header</a></h3>
<div>Second content</div>
</div>
</code></pre>
<p>And I have script file enqueued correctly, which has the following content:</p>
<pre><code>$ = jQuery;
$(document).ready(function() {
$("#accordion").accordion();
});
</code></pre>
<p>But I get this error in the console output</p>
<pre><code>TypeError: 'undefined' is not a function (evaluating '$("#accordion").accordion()')
</code></pre>
<p>The result being all divs are expanded, i.e not clickable.</p>
| jquery | [5] |
1,024,586 | 1,024,587 | How to obtain system time and update data from database automatically with an amount of time | <p>I'm a new Android dev and I'm currently developing an app which is to display ListView data from web database.</p>
<p>But what I want is to update the data based on system time.</p>
<p>Let's say right now displaying data from database:</p>
<ol>
<li>lalala</li>
<li>lololo</li>
<li>wewewe</li>
</ol>
<p>and I need to update these data automatically FROM the database every 24 hours so that the outcome will be:</p>
<ol>
<li>lilili</li>
<li>wowowo</li>
<li>popopo</li>
</ol>
<p>I've tried System.currentTimeMillis(), it does not return any values.</p>
<p>Any professional out there could help me out ?</p>
<p>Thanks in advance.</p>
| android | [4] |
5,643,257 | 5,643,258 | How to hide some markup that was added with .after()? | <p>In a nav bar I am working with, there is an arrow added to the "Active" item with jquery:</p>
<pre><code>$('.top-bar-wrapper li.active a').after('<div class="nav-active-arrow"></div>');
</code></pre>
<p>That code cannot change, I need to work with it as-is.</p>
<p>What I need to do is hide the .nav-active-arrow markup when a button is clicked. So, I have something along the lines of the following:</p>
<pre><code>var navArrow = $('.nav-active-arrow');
$('#nav-bar-churches').click( function(e) {
churchesBar.show();
navArrow.hide();
e.stopPropagation();
});
</code></pre>
<p>There is a bit more to it- for instance, I do a .show on a few events. However, the above code isn't working for me, and I'm guessing it's because <code>.nav-active-arrow</code> is created in the <code>.after()</code> function.</p>
<p>Is my thinking correct? Any suggestions?</p>
| jquery | [5] |
4,473,511 | 4,473,512 | Issue in EditText setOnKeyListener | <p>I have an <code>EditText</code>. On an <code>setOnKeyListener</code> of an <code>EditText</code> i want to perform the following action.</p>
<ol>
<li><p>On click of Done button of keyboard i want to display something in my <code>TextView</code>.</p></li>
<li><p>On click of other button not the done button i want to make the <code>TextView</code> blank.</p></li>
</ol>
<p>So for that i write the code but it works for click of done button but not for other button. so can anyone help me to solve this out.</p>
<p><strong>My Code</strong></p>
<pre><code> EditText.setOnKeyListener(new OnKeyListener()
{
public boolean onKey(View v, int keyCode, KeyEvent event)
{
if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER))
{
m_passwrdErrorText.setText(m_res.getString(R.string.passwrd_error_text));
}
else
{
m_passwrdErrorText.setText("");
}
return false;
}
});
</code></pre>
| android | [4] |
270,172 | 270,173 | Walking thru HTML in PHP | <p>Here is what I have so far:</p>
<p>My string:</p>
<pre><code>$str = "<ul>
<li><a name="valuehere1" title="titlehere" href="/channel/london/">Link1</a></li>
<li><a name="valuehere2" title="titlehere" href="/channel/games/">Link1</a></li>
<li><a name="valuehere3" title="titlehere" href="/channel/sport/">Link1</a></li>
</ul>";
</code></pre>
<p>My PHP so far (and I am stuck):</p>
<pre><code>$dom = new domDocument;
$dom->loadHTML($str);
$children = $dom->getElementsByTagName('li')->item(0)->childNodes->getAttribute('name');
$out = array();
foreach ($children as $child) {
$out[] = $dom->saveXML($child);
}
</code></pre>
<p>I am trying to extract the NAME attribute value of the A tag in the LI base on a match (in this example they are "london", "games", "sport") . WHen I pass "games" it should give me the output as "valuehere2". This has to be done at the server side due to some restrictions I have. Can someone help me with this please?</p>
<p>Thanks,
L</p>
| php | [2] |
1,338,237 | 1,338,238 | myProcess.MainWindowHandle = IntPtr.Zero for a process with a form that is visible? [C#] | <p>I have a windows service (Serv.exe) running as LocalSystem, at a certain point it wants to show the logged-on user that it is processing data, therefore I CreateProcessAsUser(Display.exe) which is a C# Windows Form that display information (this all works perfectly fine).</p>
<p>Now, when the Service is finished I want to close Display.exe - from reading around there are 2 general options. Either kill the process (which works fine in my case, but is not recommended) or use the myProcess.CloseMainWindow(); which I am currently trying to implement.</p>
<p>Here is my code:</p>
<pre><code> Process[] myProcesses;
myProcesses = Process.GetProcessesByName("Display");
foreach (Process myProcess in myProcesses)
{
if (myProcess.MainWindowHandle == IntPtr.Zero)
{
myProcess.Kill();
}
else
{
myProcess.CloseMainWindow();
}
}
</code></pre>
<p>Now, Display is simply a C# Windows Form application, I can see it on screen and my code is able to find the process (as killing it works fine) - but why is myProcess.MainWindowHandle == IntPtr.Zero? I've tried adding 15 second sleep (incase the form was still loading) but it made no difference.</p>
<p>Is there something I need to implement in Display.exe itself to process the .CloseMainWindow()? Can this have something to do with the fact that my Service (Serv.exe) running as LocalSystem is trying to get the MainWindowHandle for a process running under a different user?</p>
<p>Any help would be appreciated.
Thanks,</p>
| c# | [0] |
1,563,918 | 1,563,919 | How can I capture androids scrollstop event natively? (without using jQuery Mobile) | <p>I've got access to the full-on jQuery, not mobile. It would seem that putting in code like;</p>
<pre><code>$(document).on("scrollstop", function(){
alert(1);
});
</code></pre>
<p>isn't going to help me without jQuery Mobile. Is there any other way I can capture the scroll event consistently in Android? (2.x and up)</p>
| android | [4] |
766,430 | 766,431 | How to display selfshot capture image in camera in imageview in android | <p>I am taking user picture using self shot option in default camera in android and display it in image view in galaxy tab 7inch using android2.2 but its not displaying my code is below can anybody tell what is problem? but taking in back camera its working for self shot its not working </p>
<pre><code> startActivityForResult(new Intent("android.media.action.IMAGE_CAPTURE"), 7);
</code></pre>
<p>public void onActivityResult(int requestCode, int resultCode, Intent data)
{</p>
<pre><code>f (requestCode == 7) {
if (resultCode == RESULT_OK) {
final ContentResolver cr = getContentResolver();
final String[] p1 = new String[] {
MediaStore.Images.ImageColumns._ID,
MediaStore.Images.ImageColumns.DATE_TAKEN
};
Cursor c1 = cr.query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, p1, null, null, p1[1] + " DESC");
if ( c1.moveToFirst() ) {
String uristringpic = "content://media/external/images/media/" +c1.getInt(0);
Uri newuri = Uri.parse(uristringpic);
ImageView icon= (ImageView) findViewById(R.id.img);
icon.setImageURI(newuri);
}
c1.close();
}
}
</code></pre>
<p>}</p>
| android | [4] |
4,511,815 | 4,511,816 | How to determine one year from now in Javascript | <p>I'm trying to get one year from now's date, and it's not working.</p>
<p>JS:</p>
<pre><code>var now = new Date();
var oneYr = new Date();
oneYr.setYear(now.getYear() + 1);
$("#yearFromNow").append(oneYr.toString());
var oneMonth = new Date();
oneMonth.setMonth(now.getMonth() + 1);
$("#monthFromNow").append(oneMonth.toString());
</code></pre>
<p>Output:</p>
<pre><code>one mo. = Thu Dec 22 112 15:16:01 GMT-0500 (Eastern Standard Time)
one yr. = Sun Jan 22 2012 15:16:01 GMT-0500 (Eastern Standard Time)
</code></pre>
<p>The year has <code>Dec 22 112</code> - ?? The month is correctly displaying <code>Jan 22 2012</code>.</p>
<p>If you want to tinker with it, <a href="http://jsbin.com/alezaj/edit#javascript,html,live" rel="nofollow">http://jsbin.com/alezaj/edit#javascript,html,live</a>. This is in Chrome and Firefox.</p>
<p>Thanks!</p>
| javascript | [3] |
3,281,976 | 3,281,977 | change the background color a selected row datagridview | <p>In my datagridview, if I click on cell, background selected color of an entire row should get changed. Please guide me to do this.</p>
| c# | [0] |
920 | 921 | Buttons on a Sliding Drawer? - Android | <p>Okey, so I've implemented a button on a Sliding drawer in a android application I'm building. The only problem is that when I press the button the whole sliding drawer is pressed and it slides up.</p>
<p>I know I can disable 'press to slide up' in the XML, but that does not seem to work as the sliding drawer still is pressed just without the slide up.</p>
<p>If I call the slidingDrawer.lock(); function the button actually works but then the sliding drawer can't slide up or even be pressed up.</p>
<p>Any one have a simple solution to this problem?</p>
| android | [4] |
4,146,361 | 4,146,362 | Writing a website in Python | <p>I'm pretty proficient in PHP, but want to try something new.</p>
<p>I'm also know a bit of Python, enough to do the basics of the basics, but haven't used in a web design type situation.</p>
<p>I've just written this, which works:</p>
<pre><code>#!/usr/bin/python
def main():
print "Content-type: text/html"
print
print "<html><head>"
print "<title>Hello World from Python</title>"
print "</head><body>"
print "Hello World!"
print "</body></html>"
if __name__ == "__main__":
main()
</code></pre>
<p>Thing is, that this seems pretty cumbersome. Without using something huge like django, what's the best way to write scripts that can process get and post?</p>
| python | [7] |
5,249,722 | 5,249,723 | .animate opacity: show - need display:block; instead of display:inline; | <p>I want to show a certain element (em) on link hover.</p>
<p>I came up with this (through online tutorials).</p>
<pre><code><script type="text/javascript">
$(window).load(function() {
$("ul.slidebtns li a").hover(function() {
$(this).next("em").animate({opacity: "show"}, "fast");
}, function() {
$(this).next("em").animate({opacity: "hide"}, "fast");
});
});
</script>
</code></pre>
<p>But .animate({opacity: "show"} gives me display:inline instead of display:block - as I've read around display:block should be a default behavior... so what is wrong?</p>
| jquery | [5] |
5,916,511 | 5,916,512 | Python: Trying to gather specific information from a website | <p>Beginning programmer here. Just completed the CS61A introduction Python class @ UC Berkeley, and I was thinking of trying to implement a little program:</p>
<p>Basically, I want to be able to enter a band name, and have the program search www.setlist.fm, and return a bunch of setlists for recent concerts of that band. Sounds easy enough... I have a VERY basic idea with what to do with urllib and urlopen, but that's about it. Any pointers or guidance on how to get started?</p>
<p>Thanks!</p>
| python | [7] |
862,186 | 862,187 | I'm looking for a textbook based introduction to the php 5? Any suggestions? | <p>By textbook based i mean the author asks the reader questions/mini projects after every section/chapter of the book. And the book includes background info on php 5, like what kind of language, its use, syntax/semantix/structure etc.</p>
| php | [2] |
1,685,688 | 1,685,689 | How do I get the web page contents from a WebView? | <p>On Android, I have a <code>WebView</code> that is displaying a page.</p>
<p>How do I get the page source without requesting the page again?</p>
<p>It seems <code>WebView</code> should have some kind of <code>getPageSource()</code> method that returns a string, but alas it does not.</p>
<p>If I enable JavaScript, what is the appropriate JavaScript to put in this call to get the contents?</p>
<pre><code>webview.loadUrl("javascript:(function() { " +
"document.getElementsByTagName('body')[0].style.color = 'red'; " +
"})()");
</code></pre>
| android | [4] |
1,720,402 | 1,720,403 | What does <Object> in Map<Object> mean? | <p>I'm new to java and I don't know what this code is</p>
<pre><code>Map<Object>
</code></pre>
<p>What do they call these on java?</p>
<p>Can you tell me what does the code means? Is this casting? Can you direct me to an article leading to more examples and explanation of the said code?</p>
| java | [1] |
2,729,205 | 2,729,206 | Why does cls.__name__ not appear in dir()? | <p>Let's say I have a simple class:</p>
<pre><code>class Foobar(object):
pass
</code></pre>
<p>If I use <code>dir(Foobar)</code>, I'll get the following output:</p>
<pre><code>['__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__']
</code></pre>
<p>Even though it does not appear in the output of <code>dir()</code>, I can access <code>__name__</code>:</p>
<pre><code>Foobar.__name__
</code></pre>
<p>and get <code>Foobar</code>.</p>
<p>Why does Python behave that way?</p>
| python | [7] |
3,373,927 | 3,373,928 | python read next() | <p>next() in python does not work. what is an alternative to reading next line in python. here is a sample</p>
<pre><code>filne = "D:/testtube/testdkanimfilternode.txt"
f = open(filne, 'r+')
while 1:
lines = f.readlines()
if not lines:
break
for line in lines:
print line
if (line[:5] == "anim "):
print 'next() '
ne = f.next()
print ' ne ',ne,'\n'
break
f.close()
</code></pre>
<p>Running this on a file does not show 'ne '</p>
<p>Brgds,</p>
<p>kNish </p>
| python | [7] |
2,571,297 | 2,571,298 | C++ int to binary | <p>I am using itoa builtin function, in order to convert an integer into binary and store it in char*. Every thing works fine and output is also correct (as expected). The only thing which goes wrong is that itoa doesn't work on open source like Linux, suse.
Any suggestion for using itoa in open source environment.</p>
| c++ | [6] |
2,591,223 | 2,591,224 | Delete all files inside a folder but the last by time? | <p>I have asked the same question before and I found this solution :</p>
<pre><code>if ($handle = opendir('/path/to/your/folder'))
{
$files = array();
while (false !== ($file = readdir($handle)))
{
if (!is_dir($file))
{
// You'll want to check the return value here rather than just blindly adding to the array
$files[$file] = filemtime($file);
}
}
// Now sort by timestamp (just an integer) from oldest to newest
asort($files, SORT_NUMERIC);
// Loop over all but the 5 newest files and delete them
// Only need the array keys (filenames) since we don't care about timestamps now as the array will be in order
$files = array_keys($files);
for ($i = 0; $i < (count($files) - 5); $i++)
{
// You'll probably want to check the return value of this too
unlink($files[$i]);
}
}
</code></pre>
<p>And I have edited to fit my needs like this:</p>
<pre><code>public function cleanup() {
$files = glob("$this->location/*.sql");
$count = count($files);
if($count >= $this->maxbackups) {
$timestamps = array();
foreach( $files as $value) {
$timestamps[$value] = filemtime($value);
}
asort($timestamps, SORT_NUMERIC);
$timestamps = array_keys($timestamps);
for ($i = 0; $i < (count($timestamps) - 1); $i++) {
unlink($timestamps[$i]);
}
return $this->message->error(false,'Backups successfuly cleaned');
} else {
return $this->message->error(true,'Backups could not be cleaned');
}
}
</code></pre>
<p>But the problem is that it deletes all files but the first, not the last created, why is that ?</p>
| php | [2] |
3,567,285 | 3,567,286 | How can I perform an action on two jQuery objects? | <p>Let's suppose I have a function that is passed multiple jQuery objects.</p>
<pre><code>function manipulateStuff(obj1, obj2) { /* ... */ }
manipulateStuff($("div"), $("h1"));
</code></pre>
<p>Now let's suppose I want to perform some actions on both of them. </p>
<p>I can always repeat the code for each, or write some code that loops through them, but I don't feel like doing that. I want some way of combining the elements of multiple jQuery objects. The following code doesn't work, but it demonstrates the sort of thing I'm looking for</p>
<pre><code>$(obj1, obj2).css("color", "red");
</code></pre>
<p>Is there already a way to do this built in to jQuery? If not, can I write a small plug-in to do it?</p>
<p><strong>EDIT:</strong> to be clear, I'm manipulating <em>jQuery objects</em>, not string selectors. I am already aware of the comma operator in selectors.</p>
| jquery | [5] |
5,164,964 | 5,164,965 | How to merge four matrices of order 3*3 in to one matrix of order 6*6 | <p>I have created two matrices using Numpy in Python:</p>
<pre><code>mat=np.matrix([[1,0,0],[0,0,1],[0,0,2]])
mat1= np.matrix([[1,0,0],[0,1,0],[0,0,1]])
</code></pre>
<p>I want to merge these two matrices. How can I do that?
The output should be <code>[mat,mat1]</code></p>
| python | [7] |
1,961,060 | 1,961,061 | Get the height of a menu on page load | <p>I'm trying to set a menu, and with:</p>
<pre><code>var headed = $('#menu-main_menu li');
headed.hover(
function() {
var subed = $(this).find('ul.sub-menu').height();
var headwi = $(this).width();
$(this).find('ul.sub-menu').css({'top': -subed, 'width': headwi }).show();
},
function() {
$(this).find('ul.sub-menu').hide();
return false;
}
);
</code></pre>
<p>Here is a jsfiddle example : <a href="http://jsfiddle.net/moabi/VDZYV/2/" rel="nofollow">http://jsfiddle.net/moabi/VDZYV/2/</a>
and as you can see, it doesn't get the height on the first shot. What did i do wrong ?
(the menu is at the bottom of the page, so I want the sub-menu to go up, this is why i put the negative value)
thank you</p>
| jquery | [5] |
2,201,594 | 2,201,595 | What is IB in IPhone | <p>Any One Explain What is Interface Builder in IPhone???</p>
| iphone | [8] |
2,578,715 | 2,578,716 | Getting calender of months | <p>I'm building right now a calender, and I want to get the data of the next 10 years (how many days in any specific month,days in dates,etc). How do i get that kind of data while using java language?</p>
| java | [1] |
2,060,495 | 2,060,496 | Trouble executing a program in windows using java | <p>This is what i have so far...</p>
<pre><code>public void OpenApp() throws IOException{
getAppPath();
try {
Runtime rt = Runtime.getRuntime();
rt.exec(getAppPath(notepad.exe));
} catch (IOException ioe) { ioe.printStackTrace(); }
}
private static String getAppPath (){
String strPath = "C:\\Users\\Rafiq\\AppData\\Roaming\\Microsoft\\Windows\\StartMenu\\Programs\\Accessories" ;
return strPath;
}
</code></pre>
| java | [1] |
1,973,334 | 1,973,335 | How do you set two pairs equal to each other when one is in a vector? | <p>If you have something like <code>vector<pair<int, int> > one</code> and <code>one.push_back(make_pair(1,2))</code> if I declare another pair like <code>pair<int, int> thisOne</code> how can I make it equal to the vector element popped off of the vector?</p>
| c++ | [6] |
2,276,565 | 2,276,566 | Is it possible to detect animated gif images client side? | <p>Is it possible to detect animated gif images client side? </p>
<p>In Internet Explorer you can use the <code>onload</code> event for this, since it willl be fired for <a href="http://webbugtrack.blogspot.com/2007/11/bug-208-onload-event-fires-for-every.html">every frame loaded</a> (behaviour changed in IE8). </p>
<p>But is there a way for other browsers too?</p>
| javascript | [3] |
242,163 | 242,164 | Explode but skip the first white space - possible? | <p>I'm trying to explode this part of a json string from Google's currency calc:</p>
<p>"3 670.758 U.S. dollars"</p>
<p>I would like the value and the currency text separate, i was originally using a white-space as the separator, however i noticed when i tried to convert a 4 figure number Google was adding a space between the first and rest of the digits, to separate thousands from hundreds etc.</p>
<p>Any thoughts on how i should tackle this one?</p>
<p>I'm wondering if there is a way to explode with a white-space still but skip the first one?</p>
<p>Thanks in advance</p>
| php | [2] |
3,026,553 | 3,026,554 | Write int to text file using Writer | <pre><code>Writer wr = new FileWriter("123.txt");
wr.write(123);
wr.close();
</code></pre>
<p>Output file contains:<br>
<code>{</code></p>
<p>Where is the problem? How to write <code>int</code> to text file using <code>Writer</code>?</p>
| java | [1] |
1,982,246 | 1,982,247 | Redirecting url to a folder | <p>I had a Joomla websites once upon a time which is still in root directoy. And recently I have contstructed my website in a folder with html 5 by myself..</p>
<p>To redirect my url to my new folder I have found this and had successfull with it :
an index.html containing =</p>
<pre><code><html>
<head>
<script language="Javascript">
function goto(){
window.location.href="x.href.php"
}
</script>
</head>
<body onload="goto()">
</body>
</html>
</code></pre>
<p>But now I see that my joomla pages can still be reached and it wouldnt be a problem unless Google still shows pages from old version (joomla one) . </p>
<p>How can I redirect all pages/links to the new folder?
Can this be done via Javascript again?</p>
| javascript | [3] |
3,828,685 | 3,828,686 | Is it possible to change PRIVATE data memebers of a CLASS illigaly? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/729363/is-it-possible-to-access-private-members-of-a-class">Is it possible to access private members of a class?</a> </p>
</blockquote>
<p>Is it possible to change PRIVATE data memebers of a CLASS without Member function or Friend function,by creating object of that class and accessing address of that created object,is it possible to some how modify PRIVATE data members using such POINTERS if we know the address of that class???</p>
| c++ | [6] |
1,693,492 | 1,693,493 | Sending an image to email via PHP | <p>can you please help me with this code. i am trying to embed a image in my mail and its showing as string of alphanumeric ..</p>
<pre><code>function send_mail_pear()
{
$crlf = "\n";
$to = "mail@mail.in";
$head = ("From: mail@mail.in". "\r\n");
$head .= "Content-type: text/html\r\n";
$head .= "Content-Type: image/jpeg";
$mime = new Mail_mime($crlf);
echo $head. "<br/>";
$mime->setHTMLBody('<html><body><img src="map_6.gif"> <p>You see this image.</p></body></html>');
$mime->addHTMLImage('map_6.gif', 'image/gif');
$subject = "Test mail";
$mailBody = $mime->get();
$mail =& Mail::factory('mail');
echo $mailBody ;
/*if(mail($to, $subject, $mailBody, $head)){
echo "successful";
} else {
echo "Mail Not sent";
}
}
</code></pre>
| php | [2] |
768,173 | 768,174 | create automatic incrementor in jQuery | <p>I have to write this line saying
"10 Users have contributed 70 hours today"</p>
<p>Where the number 10 and 70 should keep incrementing by 1 every second till it reaches some threshold value and then it should again reset back to the old values and shud start incrementing</p>
<p>can anybody help me how to achieve this in jquery ?</p>
| jquery | [5] |
3,639,112 | 3,639,113 | How to get the url of the page which is currently loading i the iframe | <p>I have an requirement that, in my application on clicking an button i have to laod one more application with the same template which i was using for my application.</p>
<p>So, on clicking the button in my application i have used one intermediate page in that using iframe i passed that URL of an external application. Its working fine.</p>
<p>But the problem is in the external applicatio which is not in my control on clicking an button it is moving to next page. In that page i want to hide an button.</p>
<p>I did that also using div tag color as white and set the positions.</p>
<p>But the problem is in all the pages in the same position that is affecting. So i want to get the url of the page which is loading in the iframe on the second or third click of an external application, so that i can using some conditions i can hide the control.</p>
<p>So please any one help me to get the solution for this problem</p>
| asp.net | [9] |
2,176,796 | 2,176,797 | How can I display all images - those included with the app and on the sdcard? | <p>I want the user to be able to select from ALL images - those included with my app aswell as any they may have on their sdcard. For example, I have a .jpg file called cat.jpg in the data/com.mypackage/files folder, but it will not show in the list of images. This is the code I used, but it only displays images on the sdcard: </p>
<pre><code> // Open up a gallery browser
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select Picture"),1);
</code></pre>
<p>I know that I could have two screens, one showing my images and another showing those from the sdcard, but I would rather have all of pictures in one gallery list. </p>
<p>Any ideas?
Thank you.</p>
<p>update:
Since no one has responsed, then maybe this type of task just can't be done. I cannot find any documentation one way or the other. If someone knows where the gallery view gets its data, please let me know (docs just says images - not the source of them). Or if it is not possible to combine all images from both the phone and the sdcard in one display, I would appreciate that response also. </p>
<p>Thanks again.</p>
| android | [4] |
848,474 | 848,475 | Android: app manager | <p>Is there way to manage other apps installed on the device. For example block or suspend app for some time or set a password for it launch.</p>
| android | [4] |
863,185 | 863,186 | Show images on login form in Forms Authentication | <p>I am creating a login page using forms authentication method.
I have inserted a image in login page but image is not visible in Browser.As it is viewed in design view in Visual Studio.</p>
<p>I think there is a issue in accessing image directory by anonymous user.I have used the following code in Web.config</p>
<pre><code><location path="/images">
<system.web>
<authorization>
<allow users ="*" />
</authorization>
</system.web>
</location>
</code></pre>
| asp.net | [9] |
5,993,177 | 5,993,178 | Difference between int and numbers.Integral in Python | <p>I'm trying to get a deeper understanding in Python's data model and I don't fully understand the following code:</p>
<pre><code>>>> x = 1
>>> isinstance(x,int)
True
>>> isinstance(x,numbers.Integral)
True
>>> inspect.getmro(int)
(<type 'int'>, <type 'object'>)
>>> inspect.getmro(numbers.Integral)
(<class 'numbers.Integral'>, <class 'numbers.Rational'>, <class 'numbers.Real'>,
<class 'numbers.Complex'>, <class 'numbers.Number'>, <type 'object'>)
</code></pre>
<p>Based on the above, it seems that <code>int</code> and <code>number.Integral</code> are not in the same hierarchy.</p>
<p>From the Python reference (2.6.6) I see</p>
<blockquote>
<p>numbers.Integral - These represent elements from the mathematical set of integers (positive and negative).</p>
</blockquote>
<p>What's the difference between <code>int</code> and <code>numbers.Integral</code>? Does it have something to do with the <code>type int</code> vs <code>class numbers.Integral</code> I see in the above output?</p>
| python | [7] |
4,306,765 | 4,306,766 | Best way to time a PHP script | <p>What is the best way to see how long it takes for your PHP script to run?</p>
<p>I was thinking something like this:</p>
<pre><code>$start_time = time(); //this at the beginning
$end_time = time(); //this at the end
echo = $end_time-$start_time;
</code></pre>
<p>But how can I make it into something that is readable to me and make sense to me? </p>
| php | [2] |
2,194,750 | 2,194,751 | how to convert ddmmyyyy to mm dd yyyy in php | <p>how to convert string <strong>130812</strong> to <strong>August 13 2012</strong> and string <strong>14082012</strong> to <strong>August 14 2012 in php</strong></p>
<p>for files </p>
<pre><code>$FileForTime= MR_20121018_V002.htm;
$retDate = date ("F d Y", strtotime(substr($FileForTime,3,8)));
</code></pre>
<p>out put =<strong>October 18 2012</strong></p>
<p>but for files</p>
<p>LedgerV002130812.htm<br>
Demat14082012D004.htm<br>
which are in ddmmyy and ddmmyyyy format respectively</p>
<pre><code>$retDate = date ("F d Y", strtotime(substr($FileForTime,10,6)));
$retDate = date ("F d Y", strtotime(substr($FileForTime,5,8)));
</code></pre>
<p>output not coming??</p>
<p>not getting time stamp for extracted dates.</p>
| php | [2] |
1,803,261 | 1,803,262 | Read phone number from Tablet : Android | <p>In my application I read device phone number as </p>
<pre><code>TelephonyManager telephonyManager = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE);
// Read phone number of device owner.
String phoneNumber = telephonyManager.getLine1Number();
</code></pre>
<p>where, this will work till device having phone application. </p>
<p>But when using device is a tablet(some tablet doesn't have phone application), then what will be the value of phoneNumber? Is it will null or blank String? Or it will be an error? </p>
<p><em>I couldn't check it on emulator because SDK having Samsung Galaxy tab and that having Phone app.</em></p>
| android | [4] |
120,112 | 120,113 | Task Killer not resetting stack | <p>My application has a main Activity A and that does a StartActivity on Activity B. If somebody uses a Task Killer (e.g., Advanced Task Killer), the application is killed but when they run the app again I see the Application object is being built (onCreate called) and then it goes right into Activity B not Activity A. The Manifest has A being the Launcher Activity.</p>
<p>I also see the scenario if I run A, then Activity B, bring down notification list and run Task Killer to kill my app, and press the Back key, it creates the Application object and then Activity B object.</p>
<p>Any ideas on how to prevent this behavior? Activity B assumes that Activity A has already run. I am able to kludge this but have a boolean in the Application object which is set on Activity A. In Activity B onCreate, if that global flag is not set, I do a finish(). Must be a better way to handle this since I have quite a few activities that would experience the same behavior.</p>
| android | [4] |
4,301,857 | 4,301,858 | "implements" keyword in java? | <p>I am new to android development, I have gone through some code and found the following line of code :</p>
<pre><code>class Preview extends SurfaceView implements SurfaceHolder.Callback {
}
</code></pre>
<p>Can someone explains or give me a hint to what is really happening here especialy on implements <code>SurfaceHolder.Callback</code>?</p>
<p>thanks</p>
| java | [1] |
1,017,127 | 1,017,128 | PHP include file in foreach Loop | <p>Will I be ok doing this?</p>
<pre><code>foreach ($item as $val)
{
include('external_script.php');
}
</code></pre>
<p>Where external script is about 800 lines of code I want to keep separate for organizational sakes.</p>
<p>Gracious!</p>
| php | [2] |
1,868,111 | 1,868,112 | How to make a dynamic permission system in PHP | <p>For an application I'm building I need some kind of permission system. I want to build it myself. Now there are a couple of options.</p>
<ul>
<li>Access control list </li>
<li>Role based system</li>
<li>Group based</li>
</ul>
<p>I find ACL a bit over the top, role based only really works if you know your resources and groupbased is what I'm leaning towards, however I have an issue.</p>
<p>I have a system where <strong>Users</strong> can <em>Edit</em> artists (i.e. <strong>Superfans</strong>), all users who are eglible for this will go into some kind of <strong>group/role</strong>. But how do I (this is where the dynamic parts comes into play) appoint them to single artists? I was thinking of just 5 people per artist.</p>
<p>So basically; <strong>I need a group-based permission system that allows user-based permissions as well.</strong></p>
<p>Writing that it feels like I need ACL, but I can't make resources like: can_edit_u2, can_edit_bonjovi, can_edit_thebeatles.. or can I?</p>
| php | [2] |
3,628,702 | 3,628,703 | ECMA-262 === algorithm explanation | <p>I was trying to understand the exact algorithm for the === operator in JavaScript. It is defined as something like</p>
<blockquote>
<p>The comparison x === y, where x and y are values, produces true or false. Such a comparison is performed as follows:</p>
<ol>
<li>If Type(x) is different from Type(y), return false.</li>
<li><em>If Type(x) is Undefined, return true.</em></li>
<li><em>If Type(x) is Null, return true.</em></li>
<li>If Type(x) is Number, then
<ul>
<li>If x is NaN, return false.</li>
<li>If y is NaN, return false.</li>
<li>If x is the same Number value as y, return true.</li>
<li>If x is +0 and y is −0, return true.</li>
<li>If x is −0 and y is +0, return true.</li>
<li>Return false.</li>
</ul></li>
<li>If Type(x) is String, then return true if x and y are exactly the same sequence of characters (same length and same characters in corresponding positions); otherwise, return false.</li>
<li>If Type(x) is Boolean, return true if x and y are both true or both false; otherwise, return false.</li>
<li>Return true if x and y refer to the same object. Otherwise, return false.</li>
</ol>
</blockquote>
<p>Now if I write something like</p>
<pre><code>var t1 = undefined,t2 = 2;
typeof(t1); //"undefined"
typeof(t2); //"number"
t1 === t2; //returns false ?????
</code></pre>
<p>Consider point 2 and 3: It should return true instead.
I am testing it in Chrome 15.0.874.106 m. Can somebody explain what exactly is going on in this case?</p>
| javascript | [3] |
1,803,754 | 1,803,755 | Global variable in Javascript back to it's first value | <p>I'm trying to make a function that get two parameters and do different stuff according to which step it's on.</p>
<p>So it's like a short quest with four steps. </p>
<pre><code>var stp=1;
var vocabulary= new Array();
vocabulary['greatings']= ['привет','здорово','здравствуй'];
vocabulary['grQuestions']= ['как дела','что нового','как здоровье','как поживаешь'];
vocabulary['qrAnswers']= ['нормально как сам','спасибо хорошо','потихоньку','отлично'];
function myMission(stp,str) {
switch (stp) {
case 1:
{
if (jQuery.inArray(str, vocabulary['greatings'])!==-1) {
stp+=1;
$('.stp').html(stp);
$('.answer').html('Привет!');
} else {
$('.stp').html(stp);
$('.answer').html('Не понимаю');
}
}
break;
case 2:
alert("23");
break;
case 3:
alert("24");
break;
}
}
$(document).ready(function() {
$('#checker').click(function() {
var str = $('.yourVoice').val();
myMission(stp,str);
});
});
</code></pre>
<p>The problem is that <code>stp</code> always back to <code>1</code>
how can I fix it?</p>
| javascript | [3] |
4,269,668 | 4,269,669 | How to display List of images in two columns and number of rows | <p>In my project i have list of images i have to display them in two columns and number of rows How can i do this can any one help me out.</p>
<p>Thank you</p>
| iphone | [8] |
4,576,510 | 4,576,511 | How i Can Focus IFRAME In FireFox? | <p>i cannot focus IFRAME In FireFox , But i Can Focus it on IE as Follow:</p>
<p><strong>frames["MyFrameID"].focus();</strong></p>
<p>i have trying many solutions but all not working , Can Any One Help Me??</p>
| javascript | [3] |
3,051,032 | 3,051,033 | jQuery function not working properly | <p>Hello again SO community.</p>
<p>Is there something wrong with this piece of code:</p>
<pre><code>(function ($) {
jQuery.fn.submitAsync = function (adHocOpts, addFormObserver, skipValidation) {
$.each(this, function (i, form)
{
if (!$(form).data('submitOptions') && addFormObserver)
$(form).trigger('formLoad');
$(form).data('adHocOptions', $(form).data('submitOptions'));
$(form).mergeOptions('adHocOptions', adHocOpts);
var options = $.extend($(form).data('adHocOptions'),
{
type: form.method,//.attr('method'),
url: form.action,//.attr('action'),
data: $(form).serialize()
});
if (skipValidation)
options.validation = [];
setTimeout($.ajax(options), 10);
});
};})(jQuery);
</code></pre>
<p>I keep getting an Unexpected identifier error, and the execution is halted. Any ideas?</p>
<p>Thank you</p>
| jquery | [5] |
4,744,959 | 4,744,960 | Run code ONCE on startup | <p>I want to run a small piece of code each time the app starts up. I have tried the following:</p>
<ul>
<li>In the Activity.onCreate(). But this won't work as the activity could get re-created on rotation for example.</li>
<li>Create a subclass of Application and run in onCreate() there. This doesn't seem to work either. It gets executed when the app is installed, but not when you back-out of the application and go into it again.</li>
</ul>
<p>Any ideas?</p>
| android | [4] |
145,418 | 145,419 | need help with vector out of range error | <p>guys, I'm reading from a file and input into a vector, but I keep getting a pop up box with: "vector employees out of range!" error. It is like if I'm trying to access pass the last index in the vector, but if that's the case I don't see... any help appreciated
text file:</p>
<pre><code>123 vazquez 60000
222 james 100000
333 jons 50000
444 page 40000
555 plant 40000
</code></pre>
<p>code:</p>
<pre><code>#include <iostream>
#include <string>
#include <fstream>
#include <vector>
using namespace std;
struct employees { int id; string lname; double salary; };
void getData(vector<employees>& list, ifstream& inf);
int i = 0;
int main()
{
string filename("file2.txt");
vector<employees> list;
ifstream inf;
inf.open(filename);
getData(list, inf);
inf.close();
for(unsigned int j = 0; j < list.size(); j++)
{
cout << list[j].id << " " << list[i].lname << endl;
}
system("pause");
return 0;
}
void getData(vector<employees>& list, ifstream& inf)
{
int i = 0;
while(inf)
{
inf >> list[i].id >> list[i].lname >> list[i].salary;
i++;
}
}
</code></pre>
| c++ | [6] |
5,817,385 | 5,817,386 | Single Responsibility in C++ - Should I implement it using friend classes or more accessors? | <p>I wish to follow the Single Responsibility principle in C++. However, as I break up classes, it seems that in order for classes to "see" each other, I have the following choices:</p>
<ol>
<li>Add many more accessors for each class</li>
<li>Make classes friends of each other</li>
<li>Improve the design (maybe the fact that I would have to do 1 or 2 indicates a flaw in my design)</li>
</ol>
<p>The friend vs. accessors issue has probably been discussed before, but I did not know if one was more advantageous with regard to implementing Single Responsibility. </p>
| c++ | [6] |
1,435,602 | 1,435,603 | SMS does not get sent | <p>I am trying to make a sms sending app but the sms does not get sent. Please guide.</p>
<pre><code>package com.example.smsbomber;
import android.R.string;
import android.app.Activity;
import android.os.Bundle;
import android.telephony.SmsManager;
import android.view.Menu;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
sendLongSMS();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
public void sendLongSMS() {
String phone ="03322044685";
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(phone, null, "Message", null, null);
}
}
</code></pre>
| android | [4] |
5,257,566 | 5,257,567 | Execute dynamic HTML/JavaScript | <p>I'd like to create a textarea and a division so that whatever embed code you put in the textarea it gets executed on the division in real-time.</p>
<p>Your kind help is greatly appreciated!</p>
<p>JavaScript newbie</p>
<p>Here's an attempt:</p>
<pre><code><script type="text/javascript">
var X = " HTML or JavaScript "
window.onload=function()
{
document.getElementById("result").innerHTML = document.getElementById("input").value;
}
</script>
<textarea id="input" cols="35" rows="7"> X </textarea>
<div id="result"></div>
</code></pre>
| javascript | [3] |
2,906,517 | 2,906,518 | save bitmap image as grayscale image in C# | <p>This is my bitmap code</p>
<pre><code>Bitmap b = new Bitmap(columns, rows, PixelFormat.Format24bppRgb);
BitmapData bmd = b.LockBits(new Rectangle(0, 0, columns, rows), ImageLockMode.ReadWrite, b.PixelFormat);
</code></pre>
<p>How can i save this as a grayscale image ?</p>
<p>Well iam specifically interested in the saving part. How do i save it as a file ?</p>
| c# | [0] |
2,809,175 | 2,809,176 | Resolving memory leak from garbage collector | <p>A Java back-end system is faced with such a big load that garbage collector cannot handle and there are memory leaks. How can this be resolved?</p>
| java | [1] |
2,362,782 | 2,362,783 | How to compare columns from two csv files? | <p>I am trying to compare columns from 2 csv files.</p>
<p>In file1.csv:</p>
<pre><code>aaa,1
abc,2
bcd,2
adc,3
</code></pre>
<p>In file2.csv:</p>
<pre><code>aaa,1
abc,0
bcd,2
adc,4
</code></pre>
<p><strong>I expected to get the results "Not Equ".</strong></p>
<p><strong>If the first columns are the same but the second columns are difference.</strong></p>
<p>I tried the codes below but not success:</p>
<pre><code>import csv
file1 = 'C:/Users/Desktop/file1.csv'
file2 = 'C:/Users/Desktop/file2.csv'
reader1 = csv.reader(open(file1))
reader2 = csv.reader(open(file2))
for row1 in reader1:
text1 = row1[0].split(',')
test1sentence = text1[0]
test1class = text1[1]
for row2 in reader2:
text2 = row2[0].split(',')
test2sentence = text2[0]
test2class = text2[1]
if test1sentence == test2sentence:
if test1class != test2class:
print "Not Equ"
</code></pre>
<p>Any suggestion?</p>
| python | [7] |
3,528,499 | 3,528,500 | Android: Drawing a Picture with a clip into a scroll view causes consistent ANR? | <p>I ran into a mysterious ANR with my application which uses Pictures to record drawing command (paths, clips, text, etc.) and then draws these Pictures into Views held by a ScrollView. I was able to reproduce the issue with the below activity. In this activity, scrolling down in the ScrollView will produce an ANR as soon the bottom of the square is reached. Has anyone else ran into this? Any suggestions on how to avoid it? </p>
<pre><code>public class AnrTest extends Activity
{
public void onCreate(Bundle saveInstBundle)
{
super.onCreate(saveInstBundle);
ScrollView sc = new ScrollView(this);
MyView view = new MyView(this);
sc.addView(view);
setContentView(sc);
}
class MyView extends View
{
Picture mPic;
public MyView(Context context)
{
super(context);
mPic = new Picture();
Canvas picCanvas = mPic.beginRecording(300, 900);
Paint p = new Paint();
p.setColor(Color.RED);
picCanvas.drawRect(20, 20, 100, 100, p);
picCanvas.clipRect(0, 0, 100, 100);
mPic.endRecording();
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
{
//set a height larger than the screen, so that we can scroll.
setMeasuredDimension(300, 900);
}
protected void onDraw(Canvas canvas)
{
canvas.drawPicture(mPic);
}
}
}
</code></pre>
| android | [4] |
2,945,200 | 2,945,201 | Inject New Methods and Properties into Classes During Runtime | <p>Is there any way we can inject new methods and properties into classes during run-time.</p>
<p><a href="http://nurkiewicz.blogspot.com/2009/09/injecting-methods-at-runtime-to-java.html" rel="nofollow">http://nurkiewicz.blogspot.com/2009/09/injecting-methods-at-runtime-to-java.html</a> states we may do that by using Groovy. </p>
<p>Is it possible by just doing using Java?</p>
| java | [1] |
3,299,223 | 3,299,224 | Jquery .val() for input only works once | <p>I'm trying to create a chat box for my game.</p>
<p>The user type's their chat into the input:text feild and by ither pressing Enter or clicking the button submits the chat text.</p>
<p>This all works, however for some reason after the first time a user submits a chat message it fails to get the text from the input field.</p>
<p>Here is my code.</p>
<pre><code>$(document).ready(function() {
$("#chatEnter").live('click',function(){
var chat = $('#chatText').val();
sendChat(chat);
});
});
$(document).ready(function() {
$("#chatText").keypress(function(e){
if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13))
{
var chat = $('#chatText').val();
sendChat(chat);
return false;
}
else return true;
});
});
function sendChat(chat)
{
alert(chat); //temp test alert
$.getJSON("includes/boardUpdate.php",{chat: chat, bid: bid});
$('#chatText').val("");
}
</code></pre>
<p>It doesn't matter if i first submit a text by clicking the button or pressing enter, all future attempts submit blank entrys until I refresh the page.</p>
<p>Edit: I've tried it with and without the line to clear the text box, same results both ways.</p>
<p>Your help is appreciated. </p>
| jquery | [5] |
1,424,899 | 1,424,900 | mapkit annotation error correction on iphone | <p>i have <strong>4 annotation with same lat/long</strong> as they are pointing some location in 1 building , since <strong>they share common lat/long</strong> so i can show only one of them on map?? so is there any way to use <strong>some error correction</strong> so that i can show them Lil side by side??</p>
<p>here is my annotation code</p>
<pre><code>MKCoordinateRegion SecondRegiona;
SecondRegiona.center.latitude = 111.31888;
SecondRegiona.center.longitude = 203.861;
MyAnnotation *aSecondAnnotationa = [[[MyAnnotation alloc] init]autorelease];
aSecondAnnotationa.title = [listItems objectAtIndex:15];//@"3rd Annotation";
aSecondAnnotationa.subtitle = [listItems objectAtIndex:16];
aSecondAnnotationa.coordinate = SecondRegiona.center;
</code></pre>
| iphone | [8] |
841,248 | 841,249 | UIButton setTitleColor with RGB Vales notworking | <p>I Have to set Title color for ffe1b1 to a UIButton.RGB Value of ffe1b1 is 255,225,177,
so i am trying this code .but its not properly reflect .I search on net Color components are floats between 0.0 and 1.0 !
So what is proper way for giving That RGB Values.Thanks</p>
<pre><code> UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom] ;
btn.frame = CGRectMake(134.0, 193.0, 80.0, 30.0);
[btn setBackgroundImage:img forState:UIControlStateNormal];
[btn setTitle:@"Contact" forState:UIControlStateNormal];
[btn setTitleColor:[UIColor colorWithRed:255.0 green:225.0 blue:177.0 alpha:0.6 ]forState: UIControlStateNormal];
</code></pre>
| iphone | [8] |
1,638,874 | 1,638,875 | PHP - Can't start session suddenly on GoDaddy website | <p>I had a perfectly functional GoDaddy website (under development) before Christmas break. It has not been changed. Today, I logged on and I have all these strange errors regarding sessions that weren't there before.</p>
<p>To investigate, I made a new file and threw it on the site with the contents:</p>
<pre><code><?PHP
session_start();
echo "HELLO WORLD!";
?>
</code></pre>
<p>Navigating to this page in a freshly opened browser gives the following output:</p>
<pre><code>Warning: session_start() [function.session-start]: open(/var/chroot/home/content/05/8547705/tmp/sess_m3uikb1qe6v5hsjir8ilsfa811, O_RDWR) failed: Permission denied (13) in /home/content/05/8547705/html/try.php on line 2
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/content/05/8547705/html/try.php:2) in /home/content/05/8547705/html/try.php on line 2
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/content/05/8547705/html/try.php:2) in /home/content/05/8547705/html/try.php on line 2
HELLO WORLD!
Warning: Unknown: open(/var/chroot/home/content/05/8547705/tmp/sess_m3uikb1qe6v5hsjir8ilsfa811, O_RDWR) failed: Permission denied (13) in Unknown on line 0
Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct () in Unknown on line 0
</code></pre>
<p>I don't even know where to start with this - does anyone know what could have changed to make this basic file not work?</p>
| php | [2] |
936,956 | 936,957 | Long press Wobble Effect Iphone | <p>I have a tableview, 3 items in a cell, basically i am showing my items in grid view format with 3 columns and i am using tableview for this. This is fine. Now i want to achieve something like when i press any item on tableview/cell for long then all items will wobble and there will be small delete icon on their top left, when user press that icon then that item will be deleted, the way it happens in iphone home screen.</p>
<p>Now first i want to know is how much feasible is this idea ? Like my only 2 rows will be visible at a time, and tableview reuses cell so if i scroll down and i delete anyof the item then it wont create much hassle to manage delete of correct item right ? And i want some direction of achieving that long press and wobble effect animation of items. Any idea that would help me move further would be very helpful.</p>
<p>Thanks</p>
| iphone | [8] |
4,534,550 | 4,534,551 | Use a variable in C# path | <p>I need to save an .xml file in a specific location on a computer. But location could be changed based on selection of the user. </p>
<p>I can get user selection (from combobox) to the variable like this:</p>
<pre><code>location = (string)comboBox1.SelectedItem;
</code></pre>
<p>But I can’t use following command to store my file because of “%location%” part. It says “Could not find a part of the path” </p>
<pre><code>docSave.Save(@"C:\...\...\%location%\...\Information.xml");
</code></pre>
<p>Can anyone help me regarding that….?</p>
<p>Thank you.</p>
| c# | [0] |
4,313,967 | 4,313,968 | Reuse imagemagick process instance in asp.net app | <p>Well, creating thumbnail images in an asp.net app seems more painful then I ever thought.</p>
<p>I first used System.Drawing stuff but then I was not satisfied with the amount of code I had to write just to do some simple resizing on a fixed canvas, then I read about the controversial discussed warning by Microsoft that System.Drawing might or might not work in asp.net web context and lastly the performance of Bitmap operations was rather bad. </p>
<p>So I switchted to Imagemagick (IM) in order to generate thumbnails. This works pretty well actually as I have experience in working with IM in PHP and creating a new System.Diagnostics.Process is a simple operation. </p>
<p>However, when I need to generate many thumbs in one request (30 or more) the CPU usage goes through the roof (100%) and stays there until the last thumb is created. Of course the images are cached once they are written but still - this worries me as there are other application on the server which should not hang forever when some uncached thumbs are created.</p>
<p>If you are not familiar with Imagemagick, here is an example of how I use it:</p>
<pre><code>/path/to/im/convert.exe large.jpg ...some options... small.png
</code></pre>
<p>So for each image I create new convert.exe instance (via new System.Diagnostics.Process), and thats what probably puts so much CPU load on the server. Is there any better way to do this? Switching from Imagemagick to another image creation solution is not an option.</p>
<p>PS: Yes, this is a followup to my previous question <a href="http://stackoverflow.com/questions/1422392/imagemagick-in-asp-net-via-command-line">http://stackoverflow.com/questions/1422392/imagemagick-in-asp-net-via-command-line</a> where I stated that I would go with the caching solution, but the high CPU usage I noticed when working with larger amounts of data seems like it might be problematic.</p>
| c# | [0] |
4,672,906 | 4,672,907 | return Array To Functions with AJAX | <p>i just want to ask if how to return or how to call the returned arrays to the function..</p>
<p>this is my javascript</p>
<pre><code>$(document).ready(function(){
alert(askServer());
function askServer()
{
var strUrl = "functions.php";
var strReturn = new Array();
jQuery.ajax({
url:strUrl, success:function(html){strReturn = html;}, async:false
});
return strReturn;
}
});
</code></pre>
<p>and this is from my functions.php..</p>
<pre><code><?php
$dirArray = Array('data_1','data_2','data_3');
echo $dirArray;
?>
</code></pre>
<p>my problem is it will alert the word "Array"/...</p>
<p>can it be done like this?</p>
<pre><code>alert(askServer()[0]);
</code></pre>
<p>to alert "data_1"?</p>
| jquery | [5] |
2,770,411 | 2,770,412 | how to click a link with jquery contains | <p>I have a link that i am trying to emulate a click on. I am using the following code but nothing happens when I execute the script. Any ideas?</p>
<p>Code</p>
<pre><code>$("a:contains('somewebsite')").click();
</code></pre>
<p>Link</p>
<pre><code> <a href="http://somewebsite.com/radio.php">Radio</a>
</code></pre>
| jquery | [5] |
4,616,096 | 4,616,097 | how to get returned text from a php page | <p>very simple php question,</p>
<p>for example, demo.php just returns a text like this "hello".</p>
<p>how can i get this text from an another php page ?</p>
<p>UPDATE:</p>
<p>actually i meant page is outputting it like this "print 'hello';"</p>
| php | [2] |
1,032,143 | 1,032,144 | file_get_contents subtitute function or methods? | <p>In one's server, <code>file_get_contents</code> is disabled for security reasons. I need to retrieve xml data. So, what is the best thing to do to :</p>
<ol>
<li>Verify that <code>file_get_contents</code> is supported by a server ?</li>
<li>Is there any subtitute methods of <code>file_get_contents</code> ?</li>
</ol>
| php | [2] |
5,871,821 | 5,871,822 | How can I provide an iPhone app that will be integrated into a customer's project without providing the source code? | <p>I would like to provide my client a native iPhone application module that he could integrate within his own iPhone application.</p>
<p>I don't want to provide the source code.</p>
<p>How can I achieve this?</p>
| iphone | [8] |
2,461,754 | 2,461,755 | iPhone Add support for Backgrounder | <p>I'm trying to create a app for my personal use that uses Backgrounder.
Are there any prerequisite that the app can be used by Backgrounder as it refuses to put my app in background. </p>
<p>I have seen the wiki and Google code page of Backgrounder and it states "If you wish to run a non-AppStore 3rd-party application in the background, it is suggested that you contact the author of the application and request that proper background support be added. " </p>
<p>But there is no additional info about it... and mailing list is ... where ? Joining the group is also a mystery. </p>
<p>What constitutes a "proper background support"?</p>
| iphone | [8] |
397,932 | 397,933 | this pointer and constructor | <p>Can i safely use this pointer outside class before its constructor finished (i don't mean virtual function call from constructor)?</p>
<p>I mean something like this:</p>
<pre><code>#include <iostream>
class Bar;
class Foo
{
public:
Foo(Bar* bar);
};
class Bar
{
public:
Bar() : instance(this) {}
void foo()
{
std::cout << "Bar::foo() \n";
}
private:
Foo instance;
};
Foo::Foo(Bar* bar)
{
bar->foo(); // UB or not
}
int main()
{
Bar instance;
}
</code></pre>
<p>I've got the following warning when i tried to compile this code in MSVC-11.0</p>
<blockquote>
<p>warning C4355: 'this' : used in base member initializer list</p>
</blockquote>
<p>And what about such code?</p>
<pre><code>#include <iostream>
class Foo;
void bar(Foo* instance);
class Foo
{
public:
Foo()
{
bar(this);
}
void foo()
{
std::cout << "Foo::foo() \n";
}
};
void bar(Foo* instance)
{
instance->foo(); // UB or not
}
int main()
{
Foo instance;
}
</code></pre>
<p>I can't find any quote from standard.</p>
| c++ | [6] |
2,090,830 | 2,090,831 | jQuery – Perform function in same div as function caller | <p>I am really new to jQuery (and javascript).
I have 2 duplicated "editors" and I want to perform functions on a paragraph contained in the same div as the function caller.</p>
<p>I'm using the <code>closest</code> method to find the paragraph but I am not sure it is the best solution. Doing something with the index of the elements would be better?</p>
<p>Also, I'd like to give context to the selector to reduce the amount of DOM traversed.</p>
<p>A simplified version of the markup:</p>
<pre><code><div id="wrapper1">
<div>
<p class="paragraph">This is text of box #1</p>
</div>
<div>
<div>
<a href="#" class="doBold">Bold</a>
<a href="#" class="doItalic">Italic</a>
</div>
</div>
</div>
<div id="wrapper2">
<div>
<p class="paragraph">This is text of box #2</p>
</div>
<div>
<div>
<a href="#" class="doBold">Bold</a>
<a href="#" class="doItalic">Italic</a>
</div>
</div>
</div>
</code></pre>
<p>A simplified version of the jQuery:</p>
<pre><code> $(document).ready(function($){
var methods = {
doBold: function () { $(this).closest(':has(.paragraph)').toggleClass('bold') },
doItalic: function () { $(this).closest(':has(.paragraph)').toggleClass('italic') },
}
$('.doBold').click(methods.doBold);
$('.doItalic').click(methods.doItalic);
});
</code></pre>
| jquery | [5] |
4,686,888 | 4,686,889 | Python image processing | <p>I get that there isnt enough arguments to format string, any suggestions? It is in the else f.write line (52). This is taking the average pixel value and replacing it with a second image. As you can see the file reads both images and writes them. During the write process I get an error saying that there isn't enough arguments to format the string.</p>
<pre><code>def main():
f = open("BoardHappy.ppm","r")
lines = f.readlines()
kinds = lines[0]
size=lines[1].split()
width=int(size[0])
height=int(size[1])
depth = int(lines[2])
red=[]
green=[]
blue=[]
for i in range(3, len(lines)):
temp = lines[i].split()
for j in range(0, len(temp) ,3):
red.append(int(temp[j]))
green.append(int(temp[j+1]))
blue.append(int(temp[j+2]))
f.close()
f = open("Godzilla.ppm","r")
lines = f.readlines()
kinds = lines[0]
size=lines[1].split()
width=int(size[0])
height=int(size[1])
depth = int(lines[2])
red1=[]
green1=[]
blue1=[]
for i in range(3, len(lines)):
temp = lines[i].split()
for j in range(0, len(temp), 3):
red1.append(int(temp[j]))
green1.append(int(temp[j+1]))
blue1.append(int(temp[j+2]))
f.close()
f = open("lab5.ppm","w")
f.write("P3 \n")
width=720
height=540
f.write("%d %d \n"%(width,height))
f.write("255 \n")
for i in range(width*height):
new = (red[i]+green[i]+blue[i])/3.0
if new >=100:
f.write("%d %d %d/n"% red[i], green[i],blue[i])
else:
f.write("%d %d %d/n"% red1[i], green1[i], blue1[i])
f.close()
main()
</code></pre>
| python | [7] |
2,423,829 | 2,423,830 | Javascript to track if a click opened a new tab/window | <p>In my application when a user is clicking any "a href" link then a "loading" dialog appears (this is necessary for many reasons beyond the scope of this question). Some users, however, open some links in new tabs/windows, thus the "loading" dialog should not be shown in the opener window. Is that possible to track somehow with js?</p>
| javascript | [3] |
1,934,366 | 1,934,367 | Is there any simple way to protect the Android App and update it? | <p>I developed an Android App and installed to three users' cellphones through Eclipse and USB connection. I don't want to put the App to google market. Now I got two problems:</p>
<ol>
<li><p>How to protect the App and make it invalid in other cellphones. I know we cannot protect it 100%, I just don't want the App to be easily copied and run on other devices. What I have done was hard coding in my program to compare the AndroidID (save the AndroidID to a string and compare with current AndroidID). The problem is that if I have 100 users, I have to hard code 100 times.</p></li>
<li><p>How can I keep the users updated. Do I just upload the updated App to my own server and give them the link to download and install? In this case, the first problem comes out again: how to protect the App? </p></li>
</ol>
| android | [4] |
1,177,688 | 1,177,689 | Simple C++ Card Program. Unknown Error | <p>Ok so I am new to C++ and trying to write I simple program that is a deck of cards. But I get the errors: "unresolved externals". I have a feeling it has something to do with the instantiation in the constructor. A quick look would be appreciated.</p>
<pre><code>#include "Card.h"
#include "Deck.h"
Deck:: Deck()
{
this -> currentCard=0;
this -> index = 0;
for(int i=0;i<4;i++)
{
for(int j =0; j < 13;j++)
{
deck[index].setVal(i);
deck[index].setSuit (j);
index++;
}
}
}
void Deck::shuffle()
{
//implementation
}
Card Deck:: dealCard()
{
//implementation
}
int main (){}
</code></pre>
<p>my header file is: </p>
<pre><code>#include "Card.h"
class Deck
{
public:
Deck();
void shuffle();
Card dealCard();
private:
Card deck [52];
int currentCard;
int index;
};
</code></pre>
| c++ | [6] |
1,940,542 | 1,940,543 | Is there a more efficient way to sort two numbers? | <p>I want <code>dLower</code> and <code>dHigher</code> to have the lower and higher of two double values, respectively - i.e. to sort them if they are the wrong way around. The most immediate answer, it seems is:</p>
<pre><code>void ascending(double& dFirst, double& dSecond)
{
if(dFirst > dSecond)
swap(dFirst,dSecond);
}
ascending(dFoo, dBar);
</code></pre>
<p>But it seems like such an obvious thing to do I wondered if I'm just not using the right terminology to find a standard routine. </p>
<p>Also, how would you make that generic?</p>
| c++ | [6] |
293,797 | 293,798 | Email parsing: TypeError: parse() takes at least 2 arguments (2 given) | <p>I am getting the following error while calling a built-in function to parse an email in Python.</p>
<pre><code>txt = parser.Parser.parse(fd, headersonly=False)
</code></pre>
<p>And the error i got is </p>
<pre><code>TypeError: parse() takes at least 2 arguments (2 given).
</code></pre>
<p>Can anybody tell me the way to solve this problem?</p>
| python | [7] |
2,478,541 | 2,478,542 | Is there a way to blur a zone of an image with javascript or Jquery? | <p>Is there a way to blur a zone of an image with javascript or Jquery ?</p>
<p>Thanks</p>
| jquery | [5] |
2,803,288 | 2,803,289 | Local Build Server On Desktop | <p>I'm looking for a local build server that I can install on my machine (Windows 7) and it will then every x minutes compile my solution, run all unit tests and notify me if the build fails or a unit test fail. </p>
| c# | [0] |
5,834,815 | 5,834,816 | PHP file_put_contents and UTF-8 | <p>I have script that reads remote file content and writes it to local server. File contains characters: ąčęėįšųūž. After data insertion into local file, UTF-8 encoding is lost.
My script code:</p>
<pre><code><?php
$data = file_get_contents('remote_file_address');
echo $data; //encoding is ok
$file = dirname(__FILE__) . '/../downloads/data.csv';
file_put_contents($file,$data); //invalid encoding in data.csv file
?>
</code></pre>
<p>I also followed the instructions depending this post(<a href="http://stackoverflow.com/questions/4839402/how-to-write-file-in-utf-8-format">How to write file in UTF-8 format?</a>), but still no good.</p>
<p>So what is wrong with that? Any ideas?</p>
| php | [2] |
4,623,548 | 4,623,549 | How to set or export display variable through java code? | <p>We are required to add <code>export DISPLAY=:0.0</code> in tomcat's startup file and batch server's startup file. This is to make java see the X11 Display libraries on Unix and run our applet. Without this export in the startup files, the applet throws a Headless Exception.</p>
<p>Though this explicit export makes the java applet run, it disrupts the other applications running on the server. Is there a way where I can make this <code>export DISPLAY=:0.0</code> run from within java code instead of adding it to startup files? And if it is possible, would that be a good approach?</p>
<p>I have already tried setting the system property to <code>-Djava.awt.headless=true</code> , but it didn't work. As the link given above <a href="http://java.sun.com/developer/technicalArticles/J2SE/Desktop/headless/" rel="nofollow">http://java.sun.com/developer/technicalArticles/J2SE/Desktop/headless/</a> also says that setting headless=true would work only for few components like Canvas, Panel but it will not work for the top level components.</p>
<p>So I feel the only option left for me is using <code>export DISPLAY=:0.0</code>. This is making my applet work when set in the startup files but causes problem for other applications running in the server. So if anybody could help me to make <code>export DISPLAY=:0.0</code> work such that it doesn't interfere with other applications in the server. One way I thought was to export the display through code. </p>
<p>Any help would be highly appreciated.</p>
| java | [1] |
5,264,926 | 5,264,927 | system() mangles the command in php | <p>I'm trying to execute a command through system() in PHP. The command is /usr/bin/unzip, but the function returns with the error code 127. There is nothing else outputted. If I run the very same command directly in a shell it works.</p>
<p>The apache error log says 'sh: /unzip: not found'. I have also tried to put the command into a shell script that is in the same directory as the PHP script and call the shell script through system(). The same happens: if the shell script was called 'doit.sh' the error message in the apache log would be 'sh: /doit.sh: not found'.</p>
<p>exec() has the same behaviour.</p>
<p>The PHP version is 5.2.11-2 with suhosin extensions.</p>
<p>Any ideas what PHP could be doing to my command? </p>
| php | [2] |
5,521,005 | 5,521,006 | what is the best Serializable replacement for "Set" and "Collection" interfaces? | <p>I have to serialize Collection and Set interfaces. Which are the best Serializable replacements for those interfaces on Java?</p>
| java | [1] |
617,632 | 617,633 | How to modify this jQuery code that centers a div so that it centers it even if the browser's windows is being resized? | <p>I found this code at StackOverflow:</p>
<pre><code>/* Center Dish Popup */
jQuery.fn.center = function () {
this.css("position","absolute");
this.css("top", (($(window).height() - this.outerHeight()) / 2) + $(window).scrollTop() + "px");
this.css("left", (($(window).width() - this.outerWidth()) / 2) + $(window).scrollLeft() + "px");
return this;
}
$('#dish-popup').center();
</code></pre>
<p>It centers the div. But the div remains in the same place if you resize the browser's window. I would like to know how to change the code so that the div re-centers itself while the browser's window is being re-sized.</p>
| jquery | [5] |
2,053,639 | 2,053,640 | Android advanced scrollable View like MapView | <p>View that is scrollable similar to this picture:</p>
<p><img src="http://s13.postimage.org/7eqznyzo7/advancedscroll.png" alt="enter image description here"></p>
<p>Is there any view in Android that can scroll like MapView? I need to add an ImageView in that view. </p>
<p>I have tried <a href="http://blog.gorges.us/2010/06/android-two-dimensional-scrollview/" rel="nofollow">this</a>, but it did not work. I tried to add a ScrollView+Horizontal, but I'm getting the same results.</p>
| android | [4] |
4,487,332 | 4,487,333 | Background Image Rotator | <p>I need some suggestions and ideas to improve a background image rotator.</p>
<p>The script as of now is very basic but I'm looking to change 2 thing.</p>
<ol>
<li>I want the images to fade into each other.</li>
<li>I need to be able to preload the images so it doesn't have the delay when loading them when they first display.</li>
</ol>
<p>Thoughts?</p>
<pre><code><script type="text/javascript">
var images = ['bg1.png', 'bg2.png', 'bg3.png'];
var curImage = 0;
function switchImage()
{
curImage = (curImage + 1) % images.length
document.body.style.backgroundImage = 'url(images/' + images[curImage] + ')'
}
window.setInterval(switchImage, 5000);
</script>
</code></pre>
<p>Example: <a href="http://www.nickersonweb.com/demo/PMS/index.html" rel="nofollow">http://www.nickersonweb.com/demo/PMS/index.html</a></p>
| javascript | [3] |
4,721,189 | 4,721,190 | Copy selected contacts to other UITableView IPhone | <p>I would like to know , how can i copy and display the selected contacts from one tableview to another tablview. I have list o contacts in a tableview. I have option of multiselect contacts. when i click on done (after selecting) i need to copy the selected contacts to another tableview. Can someone guide me how can i achieve it. </p>
<p>Sample example or code will be of great use.</p>
<p>Thanks in advance. </p>
| iphone | [8] |
641,705 | 641,706 | Working with number in JavaScript | <p>How could I do this?</p>
<pre><code>1 -> 01
4 -> 04
9 -> 09
11 -> 11
22 -> 22
</code></pre>
<p>Thanks!</p>
| javascript | [3] |
903,550 | 903,551 | Android TabLayout Open different tab programaticly | <p>Hi everyone I have some problem. My application have TabLayout and I have A Dialogs when new data is coming on web service a popup message will visible. When I push the popup message button , I want to open my list which is my other activity and its place third tabs. Sorry my English , I want to open other tabs programaticly(When I push button other tabs its open. ) and I do not find any example. </p>
| android | [4] |
5,285,852 | 5,285,853 | Changing Java ListView to XML | <p>Alright, so I followed a tutorial on the Android website, and I got a ListView going in my application. But, the example they had did everything in Java basically. How could I transform the following code to XML?</p>
<pre><code>setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item, COUNTRIES));
ListView lv = getListView();
lv.setTextFilterEnabled(true);
lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// When clicked, show a toast with the TextView text
Toast.makeText(getApplicationContext(), ((TextView) view).getText(), Toast.LENGTH_SHORT).show();
}
});
</code></pre>
<p>I know I can't make the click listener XML, I just put that there for example.</p>
| android | [4] |
2,031,771 | 2,031,772 | jQuery: if value is true without user action | <p>I want to show a div if the value of an input =='CP'. </p>
<p>Right now this is my code: </p>
<pre><code>$(".register-type").change(function(){
var value = $(this).val();
if(value == 'CP'){
$('.cp-show').show();
</code></pre>
<p>This works fine if they change the input, but if things get validated false and the page reloads, this input is still 'CP', but the div doesn't show...</p>
<p>Is there a way to correct this so that jquery checks if this is set on the page load?</p>
| jquery | [5] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.