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 |
---|---|---|---|---|---|
856,098 | 856,099 | Why aren't Java weak references counted as references during garbage collection? | <p>Why are Java weak references not counted as references with respect to garbage collection?</p>
| java | [1] |
763,364 | 763,365 | Discard and print other lines in C sharp | <p>appGUID: <code>643d4128-1484-4aa1-8c17-38ae3b0cf974</code> </p>
<p>appGUID: <code>3974af88-1fb1-4ba7-84b9-59aa00c707bb</code> </p>
<p>I want my program to discard lines that contains some specific values for "appGUID" as in above.</p>
<p>My Code is here :</p>
<pre><code>IEnumerable<string> textLines
= Directory.GetFiles(@"C:\Users\karansha\Desktop\Unique_Express\", "*.*")
.Select(filePath => File.ReadLines(filePath))
.SelectMany(line => line)
.Where(line => !line.Contains("appGUID: "))
.ToList();
</code></pre>
| c# | [0] |
310,371 | 310,372 | If I use Android 4.2.2 API 17 to develop my app it can run in oldest versions? | <p>If I use Android 4.2.2 API 17 to develop my app it can run in oldest versions, like a tablet running an android 4.0 ?</p>
| android | [4] |
4,361,620 | 4,361,621 | Split html string with regex | <p>It's possible to split an html string with regex like this one</p>
<pre><code>var mystring="<p style='display:inline'>hello world</p>!!';
</code></pre>
<p>and obtain an array like this one?</p>
<pre><code>[<p style='display:inline'>,hello world,</p>,!!]
</code></pre>
<p>UPDATE: I did it using the following regex</p>
<pre><code>mystring.split(/(<\/?\w+(?:(?:\s+\w+(?:\s*=\s*(?:".*?"|'.*?'|[^'">\s]+))?)+\s*|\s*)\/?>)/gim);
</code></pre>
<p>Thank you</p>
| javascript | [3] |
653,783 | 653,784 | How can I use jQuery to set a div to be visible? | <p>I have a div as part of a page that is rendered like this:</p>
<pre><code><div id="productdiv" style="visibility:hidden;">
</code></pre>
<p>Upon a certain event, I want this div to become visible.</p>
<p>The following does not work:</p>
<pre><code>$("#productdiv").show();
</code></pre>
<p>What will work?</p>
| jquery | [5] |
3,086,395 | 3,086,396 | ASP.NET USER ROLE Issue | <p>I am trying to establish which Role for logged user. </p>
<p>Login.aspx:</p>
<pre><code>if (ValidateUser(password, userDetails.Rows[0]["Password"].ToString()))
{
FormsAuthenticationTicket tkt;
string cookiestr;
HttpCookie ck;
tkt = new FormsAuthenticationTicket(1, txtUserName.Value, DateTime.Now,
DateTime.Now.AddMinutes(3), chkPersistCookie.Checked,
userDetails.Rows[0]["Rank"].ToString(),
FormsAuthentication.FormsCookiePath);
cookiestr = FormsAuthentication.Encrypt(tkt);
ck = new HttpCookie(FormsAuthentication.FormsCookieName, cookiestr);
if (chkPersistCookie.Checked)
ck.Expires = tkt.Expiration;
ck.Path = FormsAuthentication.FormsCookiePath;
Response.Cookies.Add(ck);
string strRedirect;
strRedirect = Request["ReturnUrl"];
if (strRedirect == null)
strRedirect = "MyAccount.aspx";
Response.Redirect(strRedirect, true);
}
else
Response.Redirect("logon.aspx", true);
</code></pre>
<p>Global.aspx:</p>
<pre><code>protected void Application_AuthenticateRequest(object sender, EventArgs e)
{
if (HttpContext.Current.User != null)
{
if (HttpContext.Current.User.Identity.IsAuthenticated)
{
if (HttpContext.Current.User.Identity is FormsIdentity)
{
FormsIdentity id =
(FormsIdentity) HttpContext.Current.User.Identity;
FormsAuthenticationTicket ticket = id.Ticket;
// Get the stored user-data, in this case, our roles
string userData = ticket.UserData;
string[] roles = userData.Split(',');
HttpContext.Current.User = new GenericPrincipal(id, roles);
}
}
}
}
</code></pre>
<p>Now I am trying to get User Role but it always return me false.</p>
<pre><code> if(User.IsInRole("Manager"))
{
//Activate premium feature.
BtnAddMoney.Visible = true;
}
</code></pre>
<p>Could you guys check, what's wrong in my code?</p>
| asp.net | [9] |
5,505,752 | 5,505,753 | Javascript if-statement vs. comparsion | <p>Is it true that in if-statement JavaScript wrap the condition into a Boolean?</p>
<pre><code>if(x) => if(Boolean(x))
</code></pre>
<p>Is it true that in comparison JavaScript wrap the compare elements into a Number?</p>
<pre><code>a == b => Number(a) == Number(b)
</code></pre>
| javascript | [3] |
2,666,760 | 2,666,761 | How to convert numbers to words? | <p>How can I use Javascript for converting numbers to words? The display requires Indian rupees and paise format. </p>
| javascript | [3] |
5,975,660 | 5,975,661 | simple php script to retrieve google keyword search completion | <p>I am trying to retrieve just the search completion shown in Google search result for any keyword. For example the search completion for</p>
<p><a href="http://www.google.com/#hl=en&q=google+keyword+search" rel="nofollow">http://www.google.com/#hl=en&q=google+keyword+search</a></p>
<p>is 48,400,000 (Results 1 - 10 of about 48,400,000 for google keyword search)</p>
<p>I tried to use CURL but fail to retrieve the search result page. </p>
<p>Any help appreciated.</p>
| php | [2] |
816,416 | 816,417 | How to delete photo from iPhone photo library | <p>Is there any method to delete the photo(s) from the photo library. (NOTE: I dont want to copy the images into the document directory (sandbox), and then delete it from there; I want to refer the actual image from photo library)</p>
<p>I have different considerations, but I am not sure anyone from these will work or not (or if these are feasible):-</p>
<p>1) Getting URL of the UIImage selected, and then delete it or modify the bytes of that file to 0 size or empty.</p>
<p>2) Using Assets library, delete the image from photo library itself.</p>
<p>I want to make sure if any approach from above will work or not, or do I need something else to delete/modify the image in photo library?</p>
| iphone | [8] |
4,791,672 | 4,791,673 | Alternate three and three rows in a table with jQuery | <p>I want to set the alternate background color for rows in a table - but the twist is that I don't want every other row to be colored, I want to treat them in blocks of three rows.</p>
<p>So for a table with eight rows I want the first three to be white, then the next three to have a background color, and the last two are back to white again.</p>
<p>How can I do this using jQuery?</p>
| jquery | [5] |
4,042,799 | 4,042,800 | ListFragment like facebook/g+/youtube sliding menu | <p>i'm using this library <a href="https://github.com/iPaulPro/SlidingMenu" rel="nofollow">https://github.com/iPaulPro/SlidingMenu</a> to add a slide menu.</p>
<p>in the library example the back view ListFragment is simple and use only one xml template for all items in the list.</p>
<p>i dont want to add item by code , so how can i define an xml menu file that will be loaded to the ListFragment ?</p>
<p>i want to define an xml menu with items (like we define ActionItems in xml and load it to the actionbar)</p>
<p>is it possible ?</p>
<p>thanks</p>
| android | [4] |
39,763 | 39,764 | jquery Focus Callback | <p>Can somebody please tell me why this isnt working?</p>
<pre><code>$("textarea.settings").focus(function () {
var size = $(this).height();
console.log(size);
if(size == 40) {$(this).animate({height: 120},"slow");}
}, function () {
$(this).animate({height: 40},"slow");
});
</code></pre>
<p>please tell me why?</p>
| jquery | [5] |
5,279,508 | 5,279,509 | Create instance of "Class" Using "Reflection" in JavaScript | <p>I searched the web for some way to create instance of "Class" in "reflection" using javaScript but I found nothing.</p>
<p>generally i'm trying to do someting like java code.</p>
<pre><code>Object o = Class.forename("MyClassName");
</code></pre>
<p>but in javaScript, in such way that I'll get the instance of class when I have only the name of the class, any idea?</p>
<p>Thankes.</p>
| javascript | [3] |
4,322,991 | 4,322,992 | BASIC Javascript slider/rollovers NO JQUERY | <p>I am trying to learn <code>JavaScript</code>. </p>
<p>So I can build my own sliders, rollovers, really awesome <code>JavaScript</code> web stuff :) - without the use of plugins and such. </p>
<p>I was hoping someone could head me in the directions of building these on my own - tutorials <code>Jsfiddle</code>, etc. any suggestions?</p>
| javascript | [3] |
2,249,288 | 2,249,289 | Please explain this ambiguity? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/7718508/order-of-evaluation-of-arguments-using-stdcout">Order of evaluation of arguments using std::cout</a> </p>
</blockquote>
<pre><code>#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
static int series_num;
void setint(int num) {
series_num = num;
}
int ser() {
series_num = series_num + 23;
return series_num;
}
int main() {
setint(50);
cout << ser() << " " << ser();
getchar();
getchar();
return 0;
}
</code></pre>
<p>returns me 96 73</p>
<pre><code>#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
static int series_num;
void setint(int num) {
series_num = num;
}
int ser() {
series_num = series_num + 23;
return series_num;
}
int main() {
setint(50);
cout << ser();
cout << ser() << endl;
getchar();
getchar();
return 0;
}
</code></pre>
<p>returns me 73 and 96</p>
| c++ | [6] |
909,367 | 909,368 | Don't understand the const method declaration | <p>Too much C# and too little C++ makes my mind dizzy... Could anyone remind me what this c++ declaration means? Specifically, the ending "const". Many thanks.</p>
<pre><code>protected:
virtual ostream & print(ostream & os) const
</code></pre>
| c++ | [6] |
1,918,188 | 1,918,189 | How to extend ListActivity without declaring ListView in XML layout in android | <p>Hi guys iam developing a Screen in android.Iam writing code for that screen to work both in Portrait and Landscape orientation.Here my Portrait and Landscape XML is different,that is why iam using different XML Files for both Portrait and Landscape orientaion.Here i included that these XML Files in onConfigurationChanged() method.Depending upon the orientation change iam including that specific XML File and iam using only one activity for this which extends ListActivity.In the Portrait orientation iam using ListView but in the Landscape orientation iam not using ListView.When iam changing my orientation from Portrait to Landscape it is giving an Exception saying that Your content must have a ListView whose id attribute is 'android.R.id.list'.Here i understand the problem that in my Landscape XML File i have not used the ListView as i extended ListActivity.But i dont want to use ListView.How can i overcome this. </p>
| android | [4] |
5,994,772 | 5,994,773 | Validate vars in URL | <p>If I know what vars I can have in my URL how do I validate my URL and ignore the ones that aren't on my list?</p>
<p>I suppose I will have all 'good' vars in an array</p>
<pre><code>$good = array("name", "car", "year", "color");
</code></pre>
<p>Then I need to get the request URL, then break it apart looking for QUERY elements and loop those against my $good array, strip the ones that don't belong and process request. Seems like a good plan in theory. Or is there a better plan? If it's OK, how do I do all that? </p>
<pre><code>$url = http://mydomain.com/?car=1&color=red&bad=asdasd
</code></pre>
| php | [2] |
295,164 | 295,165 | Very simple jQuery attribute question | <p>Either I have misunderstood <a href="http://api.jquery.com/attr/" rel="nofollow">the jQuery docs for .attr()</a>, or I'm making a very stupid error. </p>
<p>Why isn't this working?</p>
<pre><code><div id="mydiv" title="mytitle"></div>
<script type="text/javascript">
$(document).ready(function(){
var username = $("#mydiv").attr("title");
alert(username);
});
</script>
</code></pre>
<p>I just get 'undefined' in the alert.</p>
| jquery | [5] |
1,471,973 | 1,471,974 | Getting the value of the selected option tag in a select box | <p>I have an select box</p>
<pre><code><select name="type1">
<option value="1">Laser Printer</option>
<option value="2">Line Printer</option>
</select>
</code></pre>
<p>Now I have a button with id <code>#New1</code> when this button gets clicked I need to display the value between the option tag that was selected. Eg if Laser Printer is selected I need to get Laser Printer and not 1</p>
<p>My code thus far</p>
<p><code>alert($("select[name=type1]:selected").val().text());</code> but this returns undefined</p>
| jquery | [5] |
3,639,989 | 3,639,990 | How can I make my app launch faster? | <p>I am experimenting with an app I am developping.</p>
<p>When I launch the app, there is currently a 3 second delay before the app UI is usable. During the delay the screen is black, apart from the task bar and, below it, the app title bar.</p>
<p>I was thinking about displaying a splashscreen as a dialog in the main Activity. However, it is only displayed after those 3 seconds, which makes it useless. This means that nearly all of the 3-second delay takes place between the launch and the call to</p>
<pre><code>super.onCreate(savedInstanceState).
</code></pre>
<p>Can anyone educate me on what is happening behing the scenes during this delay ? Is there anything I can do to shorten it ?</p>
| android | [4] |
484,835 | 484,836 | PHP Ternary Syntax Issue (been coding too long) | <p>So there is a problem with this, but i'm blind to it.
Even after reading the documentation twice (<a href="http://us.php.net/manual/en/language.operators.comparison.php" rel="nofollow">PHP Comparison Operators</a>)</p>
<pre><code>isset($items['blog']) ? unset($items['blog']) : NULL;
</code></pre>
<blockquote>
<p>Parse error: syntax error, unexpected T_UNSET</p>
</blockquote>
| php | [2] |
3,427,006 | 3,427,007 | Remove Currency Amount From String | <p>I want to remove all currency symbol and amount from page. </p>
<p>Example my string:</p>
<p>"This is $10,000 amount is not enough $20. But Make $200.45 profit them."</p>
<p>Output:</p>
<p>"This is amount is not enough . But Make profit them."</p>
<p>How do I remove through c# code.</p>
<p>If anyone can give me RegEx.</p>
| c# | [0] |
3,475,951 | 3,475,952 | Implement google earth in iphone? | <p>I am implementing one iphone applicaiton in which I want to implement google earth.</p>
<p>I have done research on net for google earth for if any google earth api available or not.</p>
<p>But I have not found sucess.</p>
<p>Can you advice me is it possible to implement google earth in our applciation.</p>
<p>Please advice me for this.</p>
<p>Thanks in advance</p>
| iphone | [8] |
4,572,717 | 4,572,718 | Will android:alwaysRetainTaskState flag save the activity intent? | <p>Suppose the current task stack of my app P contains activities: A B. A started B with some intent i.</p>
<p>A is defined with android:alwaysRetainTaskState flag. </p>
<p>Then user switched to other app, and after a while the process of P is killed by OS.</p>
<p>Then user started P from home screen. Since A has android:alwaysRetainTaskState flag, the stack will be restored to A B, and B is visible. My understanding is that, only B.onCreate() will be called and A.onCreate() will not be called. Am I right?</p>
<p>Besides, at the moment, does B still have the intent i? That is, when B calls getIntent(), will getIntent() returns null or an intent object, i?</p>
<p>Thanks!</p>
| android | [4] |
791,468 | 791,469 | Seg Fault (Whats Wrong, strcpy) | <p>In GDB I get:</p>
<pre>
(gdb) backtrace
0 0xb7d91544 in strcpy () from /lib/libc.so.6
1 0x08048982 in ISBN::ISBN(char const*, ISBNPrefix&) ()
2 0x08048d4a in main ()
(gdb)</pre>
<p>From this code:</p>
<pre><code>ISBN::ISBN(const char* str, ISBNPrefix& list) {
if(isValid(str)) {
isSet = true;
sprintf(*isbnStr,"%s",str);
}
}
</code></pre>
<p>What exactly would be causing this?</p>
<p>isbnStr is created in the header:</p>
<pre><code>class ISBN
{
...
char* isbnStr[11];
...
</code></pre>
<p>Any ideas on what I could be doing here to cause this seg fault?</p>
<p>The call in main is:</p>
<pre><code>ISBN* isbn = new ISBN("7999999008",*prefix);
</code></pre>
| c++ | [6] |
3,592,167 | 3,592,168 | Get all XML attributes value matching criteria and update the same | <p>Need to iterate through all the XML attribute value which matches a particular criteria (using XPath) and then replace the same.</p>
<pre><code><?xml version= "1.0"?>
<inventory id= "toys">
<bikes sex= "boy">
<style id= "mountain" level= "high" size= "24">
<model>24-inch Boys Mountain Bike
<price>$200.00 </price>
</model>
</style>
<style id= "cruiser" level= "mid" size= "24">
<model>24-inch Boys Cruiser Bike
<price>$150.00 </price>
</model>
</style>
</bike>
</inventory>
</code></pre>
<p>In the above XML , there are attributes like id,level, etc. I would like to loop through all the attrbiute collection whilst the value of which matched a particular value . Need to use an XPath expression . This is what I have used in the XPath . Would need the actual code through loop through the attributes
//<em>[@</em>="../"] </p>
<p>Pardon me, if I have not tried , this posting wasn't necessary</p>
| c# | [0] |
5,404,751 | 5,404,752 | Can this style of carousel be done with jQuery? | <p>This is a Flash-based gallery: <a href="http://spin.co.uk" rel="nofollow">http://spin.co.uk</a>
I love the way it works, but Flash isn't an option for me.</p>
<p>I've had a look at various plugins but couldn't find any demo or indication that this kind of setup is even possible. I don't need to jump between slides, just backwards/forwards.</p>
<p>Could anybody help me out? Thanks!</p>
| jquery | [5] |
4,837,284 | 4,837,285 | Create an Associative array in PHP | <p>How do I write PHP code to manually create this array?</p>
<pre><code>Array (
[0] => Array
(
[Id] => 2
[Fruit] => Apple
)
[1] => Array
(
[Id] => 5
[Fruit] => Orange
)
)
</code></pre>
| php | [2] |
5,571,131 | 5,571,132 | difference <?php echo '$test'; ?> and <?=$test?> | <p>What is the difference between</p>
<pre><code><?php echo '$test'; ?>
</code></pre>
<p>and </p>
<pre><code><?=$test?>
</code></pre>
<p>?</p>
| php | [2] |
2,031,966 | 2,031,967 | Assign same text to multiple DIV by jquery | <p>Suppose that I have many <code>DIV</code>s with different <code>ID</code>s and I want to insert a small snippet of html into all of those <code>DIV</code>s with different <code>ID</code>s. I tried</p>
<pre><code>$("#lblTopPager", "#lblBottomPager").html('hello my data');
</code></pre>
<p>but it doesn't work. Can anyone tell me the correct way to do it? </p>
| jquery | [5] |
1,032,544 | 1,032,545 | faster way to handle time string with python | <p>I have many log files with the format like:</p>
<pre><code>2012-09-12 23:12:00 other logs here
</code></pre>
<p>and i need to extract the time string and compare the time delta between two log records.
I did that with this:</p>
<pre><code>for line in log:
l = line.strip().split()
timelist = [int(n) for n in re.split("[- :]", l[0]+' ' + l[1])]
#now the timelist looks like [2012,9,12,23,12,0]
</code></pre>
<p>Then when i got two records </p>
<pre><code>d1 = datetime.datetime(timelist1[0], timelist1[1], timelist1[2], timelist1[3], timelist1[4], timelist1[5])
d2 = datetime.datetime(timelist2[0], timelist2[1], timelist2[2], timelist2[3], timelist2[4], timelist2[5])
delta = (d2-d1).seconds
</code></pre>
<p>The problem is it runs slowly,is there anyway to improve the performance?Thanks in advance.</p>
| python | [7] |
5,591,471 | 5,591,472 | How to have screen revert to BLACK between pages? | <p>0</p>
<p>Hi - I tried out the Background Image Scaling script and with Cybr's update it works like magic. It SCALES the image perfectly. No distortion.</p>
<p>BUT, my image isn't "computer friendly". I.e.: Not 1024 X 768 or even close to that. (Heck, my monitor has a wide screen, so it isn't 1024 X 768 either! Is anybody's anymore?)</p>
<p>Anyhow, this creates a problem inasmuch as, unless I size the window from the bottom up it ends up with a white "stripe" beneath it.</p>
<p>What I would REALLY like for it to do is have that white to be BLACK.</p>
<p>My "usual" BG color/text etc. code is like: </p>
<pre><code><body bgcolor="#000000" text="#fcba1e" link="#0000ff" vlink="#800080" alink="#ff0000">
</code></pre>
<p><del>(Site won't let me add the arrows here.)</del></p>
<p>I've tried inserting this in various places with no success. Any ideas for a workaround would surely be appreciated !</p>
<p>Thanks ! Bill</p>
| javascript | [3] |
4,203,998 | 4,203,999 | Multiple WinWord in Task Manager | <p>my c# application creates winword in task manager and close properly from taskmanager. but in case my application crashed then the winword remains opened in task manager and cannot able to process those word document.</p>
<p>so in that case i want to kill those winword alone which is created by my application and not all.</p>
<p>please help to finish this.</p>
| c# | [0] |
1,419,971 | 1,419,972 | Function returning pointer to itself? | <p>Is it possible in C++ to write a function that returns a pointer to itself?</p>
<p>If no, suggest some other solution to make the following syntax work:</p>
<pre><code>some_type f ()
{
static int cnt = 1;
std::cout << cnt++ << std::endl;
}
int main ()
{
f()()()...(); // n calls
}
</code></pre>
<p>This must print all the numbers from 1 to <code>n</code>.</p>
| c++ | [6] |
5,124,630 | 5,124,631 | I want to display table instead of displaying hi if i click menu 1 | <p>in this if i click menu1 hi will display.instead of that i want a to diaplay a table with 5 rows and 6 colunns.any one help me</p>
<h2>JavaScript</h2>
<pre><code>function displayDate1() {
document.getElementById("demo1").innerHTML=" hi";
document.getElementById("demo2").innerHTML="";
}
function displayDate2() {
document.getElementById("demo2").innerHTML="Bye";
document.getElementById("demo1").innerHTML="";
}
</code></pre>
<h2>HTML</h2>
<pre><code><h1>My First JavaScript</h1>
<a href="javascript:void(0);" onclick="displayDate1()">Menu 1</a> | <a href="javascript:void(0);" onclick="displayDate2()">Menu 2</a>
<p id="demo1"> </p>
<p id="demo2"></p>
</code></pre>
| javascript | [3] |
1,195,231 | 1,195,232 | Open a php link in a javascript popup window | <p>I have a PHP script with an link like this <code><a href='iteminfo.php?ID={$i['itmid']}]}</code></p>
<p>I want to open this link in a pop-up windows but i can't put that variable from link in javascript. My problem is that <code>$i['itmid']</code> comes from databse and for every link the id is diffrent and js get only the last variable from that array. </p>
<p>Here is my code</p>
<pre><code>if($i['weapon'])
{
$i['itmname']="<a href onclick='javascript:poponload();'><font color='red'>*</font>" .$i['itmname'] ."";
echo " <script type='text/javascript'>
function poponload()
{
testwindow = window.open('iteminfo.php?ID={$i['itmid']}', 'mywindow', 'location=1,status=1,scrollbars=1,width=500,height=500');
testwindow.moveTo(400, 130);
testwindow.focus;
}
</script>";
</code></pre>
| javascript | [3] |
4,612,279 | 4,612,280 | This jquery function doesnt work in mobile site can you help me please | <pre><code> $("select[name=merchant2]").change(function(){
$("input#mname2").val($(this).children(':selected').html())});
// the collection of initial options
$("select[name=merchantspoints]").change(function(){
$x=parseInt($(this).children(':selected').attr("name"));
$("input#mname").val($(this).children(':selected').html()) $number =1;
</code></pre>
| jquery | [5] |
2,465,914 | 2,465,915 | List all networks in android? | <p>I am gonna to implement a application, to list all the networks and manually select one of them( similar to the stock one ), can some one what kind of api can I use or what documentation should I refer to , or any reference sites ?</p>
<p>Thanks in advance !</p>
| android | [4] |
3,743,438 | 3,743,439 | Android animation doesn´t start | <p>I know it's to be something very simple, but i don't see the problem.</p>
<p>I've a LinearLayout:</p>
<pre><code>LinearLayout menuSlide = (LinearLayout) findViewById(R.id.menuSlide);
menuSlide.startAnimation(new ExpandAnimation(menuSlide, 0, (int) (screenWidth*0.7), 20));
</code></pre>
<p>And the ExpandAnimation class:</p>
<pre><code>public class ExpandAnimation extends Animation implements Animation.AnimationListener{
private View view;
private static int ANIMATION_DURATION;
private static final String LOG_CAT = "ExpandAnimation";
private int lastWidth;
private int fromWidth;
private int toWidth;
private static int STEP_SIZE=30;
public ExpandAnimation(View v,int fromWidth, int toWidth, int duration){
Log.v(LOG_CAT, "Entramos en el constructor del ExpandAnimation");
this.view = v;
ANIMATION_DURATION = 1;
this.fromWidth = fromWidth;
this.toWidth = toWidth;
setDuration(ANIMATION_DURATION);
setRepeatCount(20);
setFillAfter(false);
setInterpolator(new AccelerateInterpolator());
setAnimationListener(this);
startNow();
}
@Override
public void onAnimationEnd(Animation animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationRepeat(Animation animation) {
// TODO Auto-generated method stub
Log.v(LOG_CAT, "Entra en el onAnimationRepeat");
LayoutParams lyp = view.getLayoutParams();
lyp.width = lastWidth += toWidth/20;
view.setLayoutParams(lyp);
Log.v(LOG_CAT,"El objeto: " + view.getId() + " tiene ahora de ancho: " + view.getWidth());
}
@Override
public void onAnimationStart(Animation animation) {
// TODO Auto-generated method stub
Log.v(LOG_CAT, "Entra en el onAnimationStart");
LayoutParams lyp = view.getLayoutParams();
lyp.width = 0;
view.setLayoutParams(lyp);
lastWidth=0;
}
}
</code></pre>
<p>Ok, the program reach to the constructor of ExpandAnimation but nothing else, onAnimationStart is never fired.</p>
<p>What am i doing wrong?</p>
| android | [4] |
59,937 | 59,938 | Initialize a value in comboBox in C# | <p>I realize that my comboBox is always empty when program start. I have to click the arrow beside to choose a value. How do we do it so that the comboBox will show a value when the program start?</p>
| c# | [0] |
5,932,232 | 5,932,233 | What is the point of reassigning argument variables? | <p>I realise that it is useful (for performance reasons) to do something like...</p>
<pre><code>function Abc(a, b, c) {
var window = window;
</code></pre>
<p>So when the code accesses <code>window</code>, it doesn't need to go up the scope chain to finally find <code>window</code>. The same can be done for <code>document</code>, <code>navigator</code>, etc...</p>
<p>But I'm in the process of rewriting some of the <a href="http://code.google.com/p/mobiscroll/" rel="nofollow">MobiScroll jQuery plugin</a> and found this...</p>
<pre><code>function Scroller(elm, dw, settings) {
...
var elm = elm;
var dw = dw;
...
</code></pre>
<p>What are the advantages of reinitialising <code>elm</code> and <code>dw</code> to point to their argument variables ?</p>
<p>I've read a lot about accessing <code>arguments</code> being costly, but never read anything about why this might be good practice.</p>
<p>What are the benefits in doing this?</p>
<p><sup>In the past, I've <a href="https://developer.mozilla.org/index.php?title=en/DOM/window.onbeforeunload&action=history" rel="nofollow">deliberately removed</a> this construct from MDN documentation.</sup></p>
| javascript | [3] |
4,874,717 | 4,874,718 | Get specific content from web page with preg_match | <p>I want to get content (with all css, links working and so on) from specific web page part, which are in <code><div id="some-content"></div></code></p>
<pre><code>preg_match("/<div id=\'some-content\'>(.*)<\/div>/m", file_get_contents('www.xxx.com'), $output);
print_r ($output);
</code></pre>
<p>But it returns empty array: <code>Array ( )</code> </p>
<p>What is wrong? Is it problem with <code>preg_match</code> or with web page?</p>
| php | [2] |
2,806,999 | 2,807,000 | What does that code line means in Jquery | <p>I was studying one code and I saw this:</p>
<pre><code>var $notes = $('<ol id="notes"></ol>');
</code></pre>
<p>I thought it was the same thing of</p>
<pre><code> var $notes = $('ol#notes');
</code></pre>
<p>But I tested it and its not the same thing.....</p>
<p>Can someone enlight me ?</p>
| jquery | [5] |
337,920 | 337,921 | Returning values from Callback | <p>I don't have any previous javascript experience.</p>
<p>I'm trying to implement the following function which I wish to use to return the values lat and lng:</p>
<pre><code>function get_address() {
var geocoder = new google.maps.Geocoder()
geocoder.geocode({ address: "SE-17270 Sverige"},
function(locResult) {
var lat = locResult[0].geometry.location.lat();
var lng = locResult[0].geometry.location.lng();
alert(lat);
alert(lng);
})
}
</code></pre>
<p>How do I do this?</p>
<p>So what I want to do is something like this:</p>
<pre><code> function get_address(postcode)
{
var geocoder = new google.maps.Geocoder()
var lat
var lng
geocoder.geocode({ address: "SE-"+postcode+"Sverige"},
function(locResult) {
lat = locResult[0].geometry.location.lat();
lng = locResult[0].geometry.location.lng();
})
return lat,lng
}
</code></pre>
| javascript | [3] |
5,749,483 | 5,749,484 | What's the best technology for connecting from linux to MS SQL Server using python? ODBC? | <p>By best, I mean most-common, easiest to setup, free. Performance doesn't matter.</p>
| python | [7] |
3,334,500 | 3,334,501 | deleting specific SQL column data through PHP | <p>Hi I have a SQL table as below;</p>
<pre><code>--------------------------
col1 | col2 | col3 | col4|
--------------------------
10 | 20 | 30 | 40 |
15 | 22 | 12 | 21 |
11 | 40 | 50 | 60 |
</code></pre>
<p>and I'm trying to delete column specific data from the table. For instance I want to delete 50 and 60 in respective 3rd and 4th columns.</p>
<p>I use the following code but it deletes the entire row which contains 11 and 40 as well. Code is as follows. can some one tell me how to alter my approach below? Thanks.</p>
<pre><code> $result = mysqli_query($con,"DELETE FROM table1 WHERE col1 ='11'");
</code></pre>
| php | [2] |
302,121 | 302,122 | JavaScript string newline character? | <p>Is <code>\n</code> the universal newline character sequence in Javascript for all platforms? If not, how do I determine the character for the current environment?</p>
<p>I'm not asking about the HTML newline element (<code><BR/></code>). I'm asking about the newline character sequence used within JavaScript strings.</p>
| javascript | [3] |
896,617 | 896,618 | Detecting just started applications | <p>I need to write a java code that watches the applications. Whenever the user starts an applications (game, IE, Office...) it should write down the name of the application and the date it just started.<br>
Is this doable in Java? Can anyone provide me with some code hints?<br>
Note that am using a windows machine.</p>
| java | [1] |
2,880,076 | 2,880,077 | Adding zero to an int variable results in weird number | <p>I'm having a problem with what should be simple additon in Javascript.</p>
<p>Take a look at this firebug output:</p>
<p><img src="http://i.imgur.com/YacT4.png" alt="Firebug output screenie"></p>
<p>What I'm making is a 2D tile map in canvas, and for objects in the map that are greater than one tile in size, they have their width and height set to negative numbers, to tell me how many tiles offset in x/y they are to get to the tile with the relevant data.</p>
<p>This works fine for all cases, except when adding zero to a number. This results in strange numbers.</p>
<p>In the image above, there are two click events fired, each starting with "clicking on X x Y" and ending with "modified x/y into X Y". As you can see, clicking on a tile with a -3 for the Y offset works fine, but clicking on a tile with 0 for the Y offset results in 247!??? I've been going over and over this without getting any closer to an answer. All data seems fine, right up to the point when I try and add 0 to the variable y. If that wasn't weird enough, adding zero to the x variable works fine!</p>
<p>Here's the snippet of code that outputs the debug messages and causes the error. x and y are parameters to a function call, and cityMap is a global 3D array.</p>
<pre><code>if (cityMap[x][y]['typeID']<0)
{
// get deffered tile pos
console.debug("Offset x = "+cityMap[x][y]['width']);
console.debug("Offset y = "+cityMap[x][y]['height']);
x += parseInt(cityMap[x][y]['width'], 10);
y += parseInt(cityMap[x][y]['height'], 10);
console.debug("modified x/y into x:"+x+" y:"+y);
}
</code></pre>
<p>I'm completely lost for ideas here. Does anyone know what else I can try to stop Javascript doing this?</p>
| javascript | [3] |
423,164 | 423,165 | jquery select custom attr | <p>I have a textfield where I'm adding a custom attr called maxchars and a value of 255. I can't seem to read the value, could someone tell me what I might be doing wrong. </p>
<p>jquery</p>
<pre><code>var textarea = jQuery(this);
var maxlength = parseInt(textarea.attr("maxchars"));
</code></pre>
<p>html</p>
<pre><code><t:TextArea maxchars="255"/>
</code></pre>
| jquery | [5] |
1,473,313 | 1,473,314 | Convert string to an attribute for a nested object in javascript | <p>I am trying to access a string <code>"key1.key2"</code> as properties of an object.
For example :</p>
<pre><code>var obj = { key1 : {key2 : "value1", key3 : "value2"}};
var attr_string = "key1.key2";
</code></pre>
<p>The variable <code>attr_string</code> is a string of attributes in a nested object joined by <code>"."</code>. It can be of any depth like <code>"key1.key2.key3.key4..."</code></p>
<p>I want something like <code>obj.attr_string</code> to give the value of <code>obj["key1"]["key2"]</code> that is <code>"value1"</code></p>
<p>How to achieve this?</p>
| javascript | [3] |
1,753,338 | 1,753,339 | How to use methods from two classes in eachother in Java? | <p>I've been looking around and I only found one answer which wasn't clear enough, to me at least.</p>
<p>I am building a very basic chat application with a GUI and I have separated the GUI from the connection stuff. Now I need to call one method from GUI in server class and vice versa. But I don't quite understand how to do it (even with "this"). Here's what a part of code looks like (this is a class named server_frame):</p>
<pre><code>textField.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
try {
srv.sendData(arg0.getActionCommand());
} catch (Exception e) {
e.printStackTrace();
}
textField.setText("");
}
}
);
</code></pre>
<p>This is a code from server_frame, srv is an object from the other class (server) which contains sendData method, and I probably didn't define it correctly so hopefully someone could make a definition of it.</p>
<p>On the other side class server from which object srv was made contains method using JTextArea displayArea from server_frame in this code:</p>
<pre><code>private void displayMessage(final String message){
sf = new server_frame();
SwingUtilities.invokeLater(new Runnable(){
public void run(){
sf.displayArea.append(message);
}
}
);
}
</code></pre>
<p>Yet again sf is an object made of server_frame and yet again probably missdefined :)</p>
<p>Hopefully that was clear enough, sadly I tried the searching but it just didn't give me the results I was looking for, if you need any more info I will gladly add it!</p>
<p>Thanks for reading,</p>
<p>Mr.P.</p>
<p>P.S. Please don't mind if I made terminology mishaps, I am still quite new to java and open to any corrections!</p>
| java | [1] |
2,074,027 | 2,074,028 | Static variables initialization order | <p>I have put breakpoint into "get"</p>
<pre><code>static readonly LawClass s_Law = new LawClass();
public static LawClass Law { get { return s_Law; } }
</code></pre>
<p>and found out s_law is null. </p>
<p>How is it possible? I thought static variables are initialized before first class access and in line-by-line order.</p>
| c# | [0] |
4,779,414 | 4,779,415 | I'm an experienced C++ developer - how can I enter the gaming industry? | <p>I've been working in C++ in embedded environments for a number of years, developing navigation applications. There is a gaming company in my hometown that I like the look of, but I don't have game development experience. You could consider a navigation app as a type of game, depending on who you are running from.</p>
<p>My question is, what steps should I take to enter the industry? Is it a bad idea to enter the industry at this stage (I'm 30)?</p>
| c++ | [6] |
4,707,576 | 4,707,577 | Concatenate code object in Python | <p>I'd like to gather multiple functions (the list is unknown) in a single one dynamicly, I fugured out how to create dynamicly a python function using types.FunctionType.
However the first argument is a code object and cannot be a list of code object. How can I create a single function from multiple ones ?</p>
<p>thanks for your answer,
Jérôme</p>
| python | [7] |
4,921,593 | 4,921,594 | How to modify the Layout params of a child in a ListView in Android? | <p>Anyone help me to modify the layout params of a child in a ListView in Android.Please give some code snippets if you can.</p>
| android | [4] |
191,866 | 191,867 | JQuery Conditionally submit forms | <p>I have a table with multiple rows. Each row is a form. I want to use JQuery to submit all the forms that have the check box checked. The form is posting to an IFrame so there is not much need for AJAX.</p>
<p>So far I have:</p>
<pre><code> $("form").submit();
</code></pre>
<p>which submits the form. but all forms. There is arbritary number of rows, could be 80-100.</p>
| jquery | [5] |
142,629 | 142,630 | Why would anyone want to put an interface in an interface in Java? | <p>I am reading about what an interface contains and I understand in addition to the usual they can also contain inner classes or other interface. </p>
<p>Can anyone explain why or for what purpose anyone would want to put an interface inside an interface. Also why would anyone put an inner class inside. I have looked on the net but not found any good explanations other than a link that points to one of the standard java classes. What I really need to help me understand is a simple example.</p>
| java | [1] |
1,356,509 | 1,356,510 | Python Card Display | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/4170238/poker-hand-string-display">Poker hand string display</a> </p>
</blockquote>
<p>hi all im having a bit of a hard time figuring this question out . so if i can get any help i would greatly appreciate it. the question is ;</p>
<p>Create functions card_str(c) and hand_str(h) which return a string version of a card and a hand of
cards, respectively. A card is a string of two characters: a rank followed by a suit. A hand is a list of
cards.</p>
<pre><code>>>> print card_str("Kh")
king of hearts
>>> print hand_str([’Kh’, ’As’, ’5d’, ’2c’])
king of hearts, ace of spades, five of diamonds, deuce of clubs
</code></pre>
<p>Thanks for your time and explaining.</p>
| python | [7] |
2,524 | 2,525 | Trying to use file encryption but am getting an error with File.Encrypt(FileName) returning an exception | <p>I tried codeproject help as well as MSDN but no success. Here is a copy of my test code returning an exception:</p>
<pre><code> private void button2_Click(object sender, EventArgs e)
{
File.Decrypt("Text.pvf");
string[] DataFile = File.ReadAllLines("Text.pvf");
if (DataFile[5] == "6")
MessageBox.Show("Encrypt/Decrypt successful");
//Application.Exit();
}
private void button1_Click(object sender, EventArgs e)
{
string[] DataFile = new string[6];
DataFile[0] = "1";
DataFile[1] = "2";
DataFile[2] = "3";
DataFile[3] = "4";
DataFile[4] = "5";
DataFile[5] = "6";
File.WriteAllLines("Text.pvf", DataFile);
File.Encrypt("Text.pvf");
</code></pre>
<p>At the line: "<code>File.Encrypt("Text.pvf");</code>", I get an IOException and it says:'The request is not supported.'. Now the button1 method is called first. I do not know why this error comes up.</p>
<p>My pc: Windows7 64bit, .net 4.0, file system is NTFS as needed for File.Encryption method.</p>
<p>Please copy and paste my code to see if you can maybe spot the error. Perhaps I am missing something. Please help</p>
| c# | [0] |
3,793,867 | 3,793,868 | How to Set Off the GPS on button click in Android | <p>I have a problem that I want to OFF the GPS on button click in Android, but I unable to do that. Please suggest me the solution.</p>
<p>Thanks in advance.</p>
| android | [4] |
5,676,280 | 5,676,281 | my program doesn't accept time print out sentence | <p>Here's the code that what I have. I also have in my class file: <code>import java.util.*;</code> and <code>long time;</code> and two formulas to calculate time before and after my calculations, and there is no error.</p>
<pre><code>import java.io.*;
public class RhoMain
{
public static void main(String arg[])throws IOException
{
int n, c;//To get number and Coefficient
// BufferedReader Object to get Runtime Inputs
BufferedReader BR = new BufferedReader(new InputStreamReader(System.in));
// Getting number and Coefficient at Runtime
System.out.println("Enter a Number to be factorize : ");
n = Integer.parseInt(BR.readLine());
System.out.println("Enter a Number for coefficient : ");
c = Integer.parseInt(BR.readLine());
// Creating an Object for RhoFact Class
RhoFac1 PolFac = new RhoFac1(n,c);
int compnum = n;// Temporarily used for n
if(PolFac.succeeded() == true)
{
// Displaying the calculation Steps
System.out.println("\ty(i)\ty(2i)\td\n\n");
for (int i = 0; i != PolFac.sizeof(PolFac.aList); i++)
System.out.println("\t" + PolFac.aList.elementAt(i) + "\t"
+ PolFac.bList.elementAt(i) + "\t"
+ PolFac.dList.elementAt(i) + "\n");
System.out.println("\nfound non-trivial factor:\t" + PolFac.result
+ "\nanother non-trivial factor is:\t"
+ (compnum / PolFac.result));
System.out.println("Factorization succeeded");
System.out.println(time/1000) + " seconds");
}
else{
System.out.println("no RHO-FACTORIZATION possible with "
+ "polynom x²+" + c);
System.out.println(n + " is no valid number");
}
}
}
</code></pre>
| java | [1] |
2,405,289 | 2,405,290 | How can I get Phone wallpaper in Android? | <p>I am working on an Android application. How can I get Phone wallpaper in Android? Please help me. Give me the sample code example.</p>
| android | [4] |
4,099,445 | 4,099,446 | String split & join | <p>I have a collection of strings. I need to be able to join the items in this collection into one string and afterwards split that string backwards and get original string collection.
Definitely I need to introduce a delimiter character for join/split operation. Given the fact that original strings can contain any characters, I also need to deal with delimiter escaping. My question is very simple - is there a Java class/library that can provide me required functionality out-of-the-box? Something like:</p>
<pre><code>String join(String[] source, String delimiter, String escape);
String[] split(String source, String delimiter, String escape);
</code></pre>
<p>or similar, without having to do the work manually?</p>
| java | [1] |
190,620 | 190,621 | PHP preg match with line ends in Linux and Windows | <p>This code works on Linux but fails to match on Windows:</p>
<pre><code>if ( preg_match ( "~<meta name='date' content='(.*)'>\n<meta name='time' content='(.*)'>\n<meta name='venue' content='(.*)'>\n~", file_get_contents($filename), $matches) )
...
</code></pre>
<p>I guess the line end coding is wrong. How should I modifiy the pattern to be
end-coding independent? </p>
| php | [2] |
228,366 | 228,367 | Using Nullable Types: boolean | <p>I have a checkbox in a column of a DataGridView. Right now I got an exception because there is no checkbox checked. I am not sure how to handle it?</p>
<pre><code> private void uncheckGrid(ref DataGridView dgv, int index)
{
try
{
foreach (DataGridViewRow row in dgv.Rows)
{
DataGridViewCheckBoxCell check = row.Cells[1] as DataGridViewCheckBoxCell;
if (check.Value != null) // throw an exception here.
{
if ((bool)check.Value)
{
Int32 intVal = Convert.ToInt32(row.Cells[0].Value);
if (intVal == index)
{
check.Value = false;
}
}
}
}
</code></pre>
<p>Thanks.</p>
| c# | [0] |
5,636,975 | 5,636,976 | split a line of text into two lines using a <br> in c# | <p>I have the following code (inherited!) that will split a line of text into 2 lines with a html line break <code><br/></code>.</p>
<pre><code>public static string BreakLineIntoTwo(this HtmlHelper helper, string input)
{
if (string.IsNullOrEmpty(input)) return string.Empty;
if (input.Length < 12) return input;
int pos = input.Length / 2;
while ((pos < input.Length) && (input[pos] != ' '))
pos++;
if (pos >= input.Length) return input;
return input.Substring(0, pos) + "<br/>" + input.Substring(pos + 1);
}
</code></pre>
<p>The rules seem to be if the line of text is less than 12 characters then just return it. If not find the middle of the text and move along to the next space and insert a line break. We can also assume that there are no double spaces and no additional spaces at the end and the the text is not just one long line of letters <code>abcdefghijkilmnopqrstuvwxyz</code> etc.</p>
<p>This seems to work fine and my question is <code>Is there a more elegant approach to this problem?</code></p>
| c# | [0] |
5,527,971 | 5,527,972 | How do set request parameter value while calling java method? | <p>Hi All :
I need to call a method of java class from jsp page.. While calling that in jsp page, need to set some request parameters also. How do i do that in jsp page?</p>
<p>Ex :</p>
<p>Java class :</p>
<pre><code> public void execute() {
string msg = request.getParameter("text");
}
</code></pre>
<p>JSP file :</p>
<pre><code> I need to call the method here and also need to set parameter values (eg : &text=hello)
</code></pre>
<p>Please help me...</p>
| java | [1] |
4,342,249 | 4,342,250 | NSTimer and performing a selector on the main thread | <p>Is it possible to run a selector which is invoked by the nstimer on the main thread?</p>
<p>The NSTimer is spawned in it's own thread.</p>
<p>My structure is that a thread invokes a method with a nstimer, the nstimer invokes a method that do some updates, but I need these updates to happen on the main thread. What is the solution? Add another method and say <code>performOnMainThread</code>?</p>
| iphone | [8] |
2,181,989 | 2,181,990 | Redirect one page to another using # and page id in one file in jquery moblie phonegap in iphone not working | <p>I am new in jquery mobile with phonegap.I had done all css and js files links in index.html , But when I working in customer_registration.html and call page using #pageid , its not working, and js file also included, but its also not working. Please help..</p>
| iphone | [8] |
546,143 | 546,144 | positions in a list. python | <p>Lets say I have this list:</p>
<pre><code> lst = [[0], [0, 0], [0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0, 0]...]
</code></pre>
<p>how can I add a certain number to each cell according to its position in the lists
for exapmle:
I want to add a formula to each cell by multipying 3 with the position on the list*position in the nested list
so lets say the second cell on the third list will be </p>
<pre><code> 3*3*2
(random number)*(the third nested list)*(second spot on that list)
</code></pre>
<p>so eventually the list will look like that (only for the number 3)</p>
<pre><code> lst = [[3], [6, 12], [9, 18, 27], [12, 24, 36, 48], [15, 30, 45, 60, 75]...]
</code></pre>
<p>anyway this is just an example and Im asking generally about how to apply a certain formula considaring the position of nested list and inner cells in a list.
Its kind of difficult to explain so I hope it came out clear enough.
thank you.</p>
| python | [7] |
5,028,087 | 5,028,088 | not able to open links in a new tab | <p>I need to verify a lot of links on a page. Rather than opening each link myself. This is what I did. </p>
<p>jquerified the page using firequery plugin. Then I typed following code in firebug.</p>
<pre><code>a = $('a');
$.each(a, function(i,val){
$val = $(val);
$val.attr({target: '_blank'});
$val.trigger('click');
});
</code></pre>
<p>Even though I am trigger click the links were not clicked. Why?</p>
| jquery | [5] |
1,419,387 | 1,419,388 | Is there a way to obtain the path to ProgramData in Windows using javascript? | <p>I need to obtain the path to the APPDATA for the current user in Windows(XP, Vista, 7, 8), using javascript.
Is there a way to do this?</p>
| javascript | [3] |
3,986,812 | 3,986,813 | storing ajax result into PHP session | <p>I see examples how to fetch data from php to ajax (and display it via javascript.) As in log-in example, we can check whether there is a valid email and password entered, we can simply display "You are now logged in." Till here I understand and work out. But, now as the user logs in, I need to set the php session.
The login form sends data to the ajax.php, which simply returns a success message. In other case, if I just use php to check valid login details, I can set php session as soon as the script finds match data. </p>
<p>I know I can send ajax data through URL to second php page, where it can access through $_GET. But I want to get that data into SESSION rather than sending through URL. </p>
<p>How I do that?</p>
| php | [2] |
2,450,917 | 2,450,918 | how to run unix commands from java | <p>I want to execute some Unix commands from the java code.</p>
<p>I want to run logcat command from java code.</p>
<p>I am using the below code to do this:</p>
<pre><code> Process p = Runtime.getRuntime().exec("logcat -v time -f /mnt/sdcard/abc.txt");
</code></pre>
<p>The above code is working perfectly.</p>
<p>The same way I want to run some other Unix commands .</p>
<p>I want to run "WC -l"(read no.of lines in file) command and I want to store it out put in some integer.</p>
<p>Below is the code that I have written for this:</p>
<pre><code> Process p = Runtime.getRuntime().exec("wc -l /mnt/sdcard/abc.txt");
</code></pre>
<p>But it is throwing below exception.</p>
<pre><code> 08-19 05:34:53.457 W/System.err( 1269): java.io.IOException: Error running exec(). Command: [wc, -l, /mnt/sdcard/abc.txt] Working Directory: null Environment: null
08-19 05:34:53.457 W/System.err( 1269): at java.lang.ProcessManager.exec(ProcessManager.java:224)
08-19 05:34:53.457 W/System.err( 1269): at java.lang.Runtime.exec(Runtime.java:189)
08-19 05:34:53.457 W/System.err( 1269): at java.lang.Runtime.exec(Runtime.java:275)
08-19 05:34:53.457 W/System.err( 1269): at java.lang.Runtime.exec(Runtime.java:210)
</code></pre>
<p>Please help me what's the issue in this..</p>
<p>I have a file "abc.txt" in SD card.</p>
<p>is it possible to execute "WC -l" command from java code of android.</p>
<p>If we can execute Unix commands from java code we can make file operations very easier.</p>
| android | [4] |
4,086,637 | 4,086,638 | in_array confused about strict option | <p>When I use strict option (which I was expected to be the best option since I'm comparing numbers to numbers) if never comes out true. But without strict it works fine! I'm just checking if array already contains post_id. If doesn't not add, if yes don't add duplicate.</p>
<pre><code>if (!in_array($post->ID, $cookie_value)) {
array_unshift($cookie_value, $post->ID);
}
print_r($cookie_value);
Array ( [0] => 25 [1] => 1 )
</code></pre>
<p>So what is the deal here?</p>
| php | [2] |
661,450 | 661,451 | php REQUEST_URI | <p>I have the following php script to read the request in URL :</p>
<p><code>
$id = '/' != ($_SERVER['REQUEST_URI']) ? str_replace('/?id=' ,"", $_SERVER['REQUEST_URI']) : 0;
</code></p>
<p>It was used when the URL is <a href="http://www.testing.com/?id=123" rel="nofollow">http://www.testing.com/?id=123</a></p>
<p>But now I wanna pass 1 more variable in url string <a href="http://www.testing.com/?id=123&othervar=123" rel="nofollow">http://www.testing.com/?id=123&othervar=123</a></p>
<p>how should I change the code above to retrieve both variable? </p>
| php | [2] |
4,378,435 | 4,378,436 | Xampp apache crashed php rar | <p>I have rar extensions installed on php using xampp go-pear</p>
<p>It shown in php info that rar is enabled.</p>
<p>My code is following</p>
<pre><code><?php
$rar_file = rar_open('htdocs.rar') or die("Can't open Rar archive");
$entries = rar_list($rar_file);
foreach ($entries as $entry) {
echo 'Filename: ' . $entry->getName() . "\n";
echo 'Packed size: ' . $entry->getPackedSize() . "\n";
echo 'Unpacked size: ' . $entry->getUnpackedSize() . "\n";
$entry->extract('C:/xampp/htdocs');
}
rar_close($rar_file);
?>
</code></pre>
<p>rar_open causes apache to crash. if i comment out rar_open, apache wont crash and run as normal.</p>
<p>Anyone know what make it crash?</p>
<p>Thanks</p>
| php | [2] |
4,099,108 | 4,099,109 | jQuery jPicker users: hexadecimal returns 8 digit value? | <p>I've just about got the jPicker script working flawlessly in my app. However, the value it returns contains 8 digits. Example: 212ebcff</p>
<p>Is there a preset variable that forces jPicker to return a 6 digit hex value?</p>
| jquery | [5] |
5,114,373 | 5,114,374 | SAX parser getting error while parsing special character " : " | <pre><code> <media:group>
<media:content type="video/mp4"
url="http://cdn2.junctiontv.net/dmv/roku/ChiroDiniTumiJeAmar2997fps800kbpsForIPTV.mp4"
bitrate="800"
duration="8100"/>
</media:group>
<media:thumbnail
url="http://cdn2.junctiontv.net/dmv/images/ChiroDiniTumiJeAmar158x204.png"/>
</code></pre>
<p>I am trying to parse this xml using SAX Parser. But am getting error due to : in the tags. However if I replace remove : ie, change to its working fine. But problem is ,if I do this, am getting error in url as : is removed after http.</p>
<p>any solution?????????</p>
| android | [4] |
2,061,728 | 2,061,729 | is this possible to create subdirectory in FTP using ftp.MakeDirectory? | <p>I have to create this query to get some answer before i change my code.Pardon me if this question is doesn't make sense to you guys.</p>
<p><strong>Scenario 1:</strong></p>
<pre><code>string path :ftp://1.1.1.1/mpg/test";
FtpWebRequest requestDir = (FtpWebRequest)FtpWebRequest.Create(new Uri(path));
requestDir.Credentials = new NetworkCredential("sh","se");
requestDir.Method = WebRequestMethods.Ftp.MakeDirectory;
</code></pre>
<p>Using the same code to create the directory structure to connect my local Filezilla ftp server to do the job---Works Fine.</p>
<p><strong>Scenario 2:</strong>
Used the above code to connect the remote ftp server to do the same job throws exception : Error 550 no file found or no Access.</p>
<p><strong>Question 1</strong> : I have a full permission to read/write for the folder,if its not a permission issue,what else i have to keep it in mind to look for it ?</p>
<p><strong>Question 2</strong>: If i modified my code like
step1: Make"mpg" direcotry first
step2: make"test" directory after that,works fine
is that mean FTP.Makedirectory won't support to create a subdirectory in the main dir ?</p>
<p>If that's the case how it created in my local ftp server ?</p>
<p>Any help appreciated.</p>
<p>Thanks in Advance.</p>
| c# | [0] |
76,048 | 76,049 | Executing JavaScript when a link is clicked | <p>Which is preferable, assuming we don't care about people who don't have JavaScript enabled?</p>
<pre><code><a href="#" onclick="executeSomething(); return false"></a>
</code></pre>
<p>Or</p>
<pre><code><a href="javascript:executeSomething()"></a>
</code></pre>
<p>Is there any difference? </p>
<p>Or there any other ways I'm missing besides attaching an event to the anchor element with a JavaScript library?</p>
| javascript | [3] |
4,792,713 | 4,792,714 | How to use sqlserver to store session state? | <pre><code><sessionState mode="SQLServer"
cookieless="true"
regenerateExpiredSessionId="true"
timeout="30"
sqlConnectionString="Data Source=MICHAEL;Integrated Security=SSPI;"
stateNetworkTimeout="30"/>
</code></pre>
<p>I wonder what I am doing wrong.</p>
| asp.net | [9] |
3,451,740 | 3,451,741 | How to run jar files | <p>I have a Win XP machine which has java installed on it. The problem that I cannot open jar files. It seems that association is broken. How can I launch jar files by using console. Or maybe there is a way to set a proper association.</p>
| java | [1] |
4,723,133 | 4,723,134 | How to plot a marker with latlog in ocean area | <p>I would like to know is it possible for google map able to set marker in ocean area if latlog given? If yes, plz give code samples for me. Thanks</p>
| javascript | [3] |
969,202 | 969,203 | jquery disable parts of page | <p>I am displaying a modeless jquery dialog on top of a page. When the dialog is displayed I wish to only allow the user to interact with a certain portion of the page (mainly because I do not want them naving away or clicking other controls that cause postbacks). I thought it would work well to use the same mechanism that jquery uses with a modal dialog except instead of disabling the entire page, disable all but the portion I wish to remain active. Does someone know how jquery modal dialog does this or have a better suggestion?</p>
| jquery | [5] |
5,534,049 | 5,534,050 | Can I chain this jQuery? | <p>Is it possible to shorten these jQuery snippets by chaining them together? For the second chain, I'd like to get rid of the <code>w</code> class if possible.</p>
<pre><code>$('#content').prepend("<h1 />");
$('#content h1').append( $('#content>p:first strong').html() );
$('#content>p:first strong').parent().remove();
$('font').wrapInner('<p class="w"/>');
$("p.w").unwrap().unwrap();
</code></pre>
<hr>
<p><strong>Edit:</strong> Let me clarify my second jQuery snippet. I'm cleaning up old HTML markup that looks like this:</p>
<pre><code><div id="content">
<p>
<font>
<b>Sample Title</b>
<br>
More sample text.
</font>
</p>
</div>
</code></pre>
<p>And changing it to this:</p>
<pre><code><div id="content">
<p>
<b>Sample Title</b>
<br>
More sample text.
</p>
</div>
</code></pre>
| jquery | [5] |
4,930,275 | 4,930,276 | how to combined between "easy silder" & "prety photo" jquery plugins? | <p>i have a problem put 2 jquery scripts in one page. only one is working until i remove the second script the other working.
here is the code of easy slider</p>
<pre><code><script type="text/javascript" src="js/jquery.js"></script>
</code></pre>
$(document).ready(function(){
$("#slider").easySlider({
auto: true,
continuous: true
});
});
<p>i put it in the head tags.</p>
<p>and here is pretty photo script i put it before the end of body tag.</p>
<pre><code><script type="text/javascript" charset="utf-8">
</code></pre>
<p>$(document).ready(function(){
$("a[rel^='prettyPhoto']").prettyPhoto();
});
wish anybody can give me answer to make both of them work in same page.
here is my website you can check the problem
<a href="http://www.osmanassem.com/" rel="nofollow">http://www.osmanassem.com/</a>
thank you</p>
| jquery | [5] |
3,278,152 | 3,278,153 | checkdnsrr error with php 2.9.2 | <p>i am trying to use checkdnsrr() function with php 2.9.2, but it shows an error as "Call to undefined function checkdnsrr()".. is it because this function is not compatible with the version i am using? Can i have an alias of this function so that it works with my version?</p>
| php | [2] |
1,190,577 | 1,190,578 | updating object state from another class | <p>Hello all i'm a noob here and to oophp.</p>
<p>I'm looking to update an exiting objects state from another class.</p>
<p>So in the main file i have...</p>
<pre><code>$obj1 = new class1();
$obj2 = new class2();
</code></pre>
<p>and in class1 i have i setter method that changes the objects state.</p>
<p>soooo what i'm looking at doing, from within an existing method of class2 is something like this...</p>
<pre><code>$obj1->updateName('Bob');
</code></pre>
<p>Static Methods are no good as i have to relate to the same objects state later. </p>
<p>here's a one page example....</p>
<pre><code>class class1(){
private $name = '';
public function updateName($nameIn){
$this->name = $nameIn;
}
}
class class2(){
public function someFuntion(){
//OTHER CODE//
$obj1->updateName('Bob');
}
}
$obj1 = new class1();
$obj2 = new class2();
$obj2->someFuntion();
</code></pre>
<p>Hope this makes some sense.</p>
| php | [2] |
4,797,041 | 4,797,042 | copy to vector giving segfault | <p>I am trying to copy the vector data from <code>sample</code> to <code>Y</code> as below</p>
<pre><code>std::map<std::string, std::vector<double > >sample;
std::map<std::string, std::vector<double > >::iterator it1=sample.begin(), end1=sample.end();
std::vector<double> Y;
</code></pre>
<p>and am using the following code:</p>
<pre><code> while (it1 != end1) {
std::copy(it1->second.begin(), it1->second.end(), std::ostream_iterator<double>(std::cout, " "));
++it1;
}
</code></pre>
<p>It prints the output ok, however when I replace the above std::copy block with the below, I get a segfault.</p>
<pre><code> while (it1 != end1) {
std::copy(it1->second.begin(), it1->second.end(), Y.end());
++it1;
}
</code></pre>
<p>I just want to copy the contents of it1->second to Y. Why is it not working and how do I fix it?</p>
| c++ | [6] |
4,488,150 | 4,488,151 | Prevent deadlock shared boost mutex | <p>I want to use a shared mutex so threads only get locked when a vector/map/whatever is written to rather than read from. But I think func2() will never get the uniqueue lock because func1() will never get to unlock. Is there any way to not count a same-thread lock on shared_mutex when trying to get the uniqueue lock? Or would the problem still occur even then? </p>
<p>I'm guessing I need to find a way to force-get the lock (one thread at a time) once all threads have reached func2() OR have released the lock.</p>
<pre><code>func2()
{
boost::unique_lock<boost::shared_mutex> lock_access3(shared_mutex);
/*stuff*/
lock_access3.unlock();
}
func1()
{
boost::shared_lock<boost::shared_mutex> lock_access1(shared_mutex);
func2();
lock_access1.unlock();
}
</code></pre>
| c++ | [6] |
5,020,221 | 5,020,222 | How do I make PHP display files in the opposite order that readdir does? | <p>I'm using this to return images in the order they were added to the directory, however I want them to be ordered from newest to older. How can I do it? Thanks</p>
<pre><code><?
$handle = @opendir("images");
if(!empty($handle)) {
while(false !== ($file = readdir($handle))) {
if(is_file("images/" . $file))
echo '<img src="images/' . $file . '"><br><br>';
}
}
closedir($handle);
?>
</code></pre>
| php | [2] |
4,034,274 | 4,034,275 | C# check if a process exists then close it | <p>I'm trying to Close a process within C# but how do I check if is open first? Users asked for this feature and some of them will be still using the close button of the other process.</p>
<p>So, right now works fine:</p>
<pre><code>Process.GetProcessesByName("ProcessName")[0].CloseMainWindow();
</code></pre>
<p>Now, how do I check first that it exists, this doesn't work:</p>
<pre><code>if ( Process.GetProcessesByName("ProcessName")[0] != null ) {...}
</code></pre>
| c# | [0] |
2,209,867 | 2,209,868 | If element is over another element? | <p>With jQuery how do i find out if div <code>one</code> is over div <code>two</code>? Not, which z-index is higher but what div is visually over the other div.</p>
<pre><code><style type='text/css'>
#one {
position:absolute; top:0; left:0; width:100px; height:100px; background-color:red; z-index:2;
}
#two {
position:absolute; top:0; left:0; width:100px; height:100px; background-color:green; z-index:1;
}
</style>
<div id='one'></div>
<div id='two'></div>
</code></pre>
| jquery | [5] |
4,151,728 | 4,151,729 | Function to count how many numbers are there with the digits and division value specified | <p>I started making a function that will be able do the following: <em>Count how many 6 digit numbers you can make with the digits 0,1,2,3,4 and 5, that can be divided by 6?</em></p>
<p>How I currently try to start, is I make an array of all the possible numbers, then take out every number that has any of the <code>numbers</code>' arrays elements in it, then remove the ones that are not dividable with 6. </p>
<p>I got stuck at the second part. I tried making 2 loops to loop in the array of <code>numbers</code>, then inside that loop, create an other one for the length of the <code>allnumbers</code> array to remove all matches.</p>
<p>Then I would use the <code>%</code> operator the same way to get every element out that doesn't return 0.</p>
<p>The code needs to be flexible. If the user asks for eg. digit 6 too, then the code should still work. Any way I could finish this?</p>
<p>My Code is:</p>
<pre><code>var allnumbers = [],j;
var biggestnumber = "999999999999999999999999999999999999999999999999999999999999";
function howmanynumbers(digits,numbers,divideWith){
if (digits && numbers && divideWith){
for (var i = 0; i < 1+Number(biggestnumber.substring(0,digits)); i++ ){
allnumbers.push(i);
}
for (j = 0; j < numbers.length; j++ ){
var matchit = new RegExp(numbers[j]);
}
//not expected to work, I just had this in for reference
if ( String(allnumbers[i]).match(matchit) != [""]){
j = 0;
allnumbers.splice(i,1);
var matchit = new RegExp(numbers[j])
}
}
else {
return false;
}
}
</code></pre>
| javascript | [3] |
1,965,499 | 1,965,500 | What is the right way to write 'Get' method? | <p>With one of mine coworkers often argue about "the right way" of writing 'Get' methods.
My opinion is <code>object GetSomeObject()</code>. My colleague thinks it is better to be <code>void GetSomeObject(object obj)</code>. I know the result is one and the same in both cases. I want to hear and other opinions. Ohhh i forgot to tell for what platform we are talking about - .NET Framework the language is C#.</p>
| c# | [0] |
5,811,635 | 5,811,636 | how to find the expired date in php | <p>hi i need to find whether the given date is passed or future.</p>
<pre><code>$elapsedTime = new DateTime('2011-03-15 00:20:00');
$elapsedInt = $elapsedTime->diff( new DateTime() );
echo ( $elapsedInt->invert ? 'Future' : 'Past' ) . "<br/>";
</code></pre>
<p>i tried this code but i am getting error because my php version was 5,2.And i cant update.</p>
<p>can any one help me ?</p>
| php | [2] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.