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 |
|---|---|---|---|---|---|
5,505,075 | 5,505,076 | Search Files& Dirs on Website | <p>Hi im coding to code a Tool that searchs for Dirs and files.</p>
<p>have done so the tool searchs for dirs, but need help to make it search for files on websites.</p>
<p>Any idea how it can be in python?</p>
| python | [7] |
1,736,081 | 1,736,082 | adding text to image using python | <p>Is the following function correct, this code is meant to add a phrase to image. Note that i cannot use image.text function or any other but can only use getpixel, putpixel, load, and save.</p>
<pre><code>def insertTxtImage(srcImage, phrase):
pixel = srcImage.getpixel(30,30);
srcImage.putpixel(pixel,phrase);
srcImage.save;
pass
</code></pre>
<p>Yes it is homework which can only use getpixel, putpixel, load, and save to insert a phrase in to the image.</p>
<p>I tried to do this with this code but it is giving system error (argument is not a tuple)</p>
<p>def insertTxtImage(srcImage, phrase):<br>
pix = srcImage.load()<br>
pix[0,0] = phrase<br>
srcImage.save()<br>
pass </p>
<p>Thanks for the comments.</p>
| python | [7] |
1,015,911 | 1,015,912 | How to query C# DataTable? | <p>I have created and returned datatable, this table has 10 columns. Now i want to filter from this table based on some dynamic search parameters. How to do this? any idea would be timely help.</p>
<pre><code>// This function will create and return the source table.
var DisplayTable = CreateQueryTable();
</code></pre>
<p>Here I want to do dynamic search like <code>If col1=MyName and Col2=MyCity</code> </p>
<pre><code>ResultGrid.DataSource = DisplayTable;
ResultGrid.DataBind();
Panel1.Controls.Add(ResultGrid);
</code></pre>
| c# | [0] |
4,879,882 | 4,879,883 | jquery form input select by id | <p>This is very very simple but strangely absent from the web (hummm...)</p>
<pre><code><form id='a'>
<input id='b' value='dave'>
</form>
</code></pre>
<p>How do I get the value from input 'b' while at the sametime make sure it's inside 'a' (something like <code>$('#a:input[id=b]')</code>).</p>
<p>I only ask because I might have other input's called 'b' somewhere else in my page and I want to make sure I'm getting the value from the right form</p>
| jquery | [5] |
4,341,810 | 4,341,811 | string user function | <p>how can i add a custom function to a string type</p>
<p>example: </p>
<pre><code>string test = "hello";
test.userFn("world");
public string userFn(strng str) {
return " " + str;
}
</code></pre>
| c# | [0] |
6,005,465 | 6,005,466 | Android: Converting OnItemClick to OnClickListener | <p>previously I have this OnItemClick method which enables the user to click the row on the listview and leads to a new activity bringing some attributes (texts,image) to a new activity</p>
<pre><code>public void onItemClick(AdapterView<?> l, View v, int position, long id) {
Intent listIntent = new Intent(this, DetailsActivity.class);
listIntent.putExtra("spendino.de.ProjectDetail.position",position);
listIntent.setData(Uri.withAppendedPath(Uri.withAppendedPath(
Provider.CONTENT_URI, Database.Project.NAME), Long
.toString(id)));
startActivity(listIntent);
}
</code></pre>
<p>But now I just implemented a 'View' to my CursorAdapter. It's impossible to implement <code>onItemClick</code> to the row layout, what I can do is implement onClick to it. But I'm having trouble converting the method content from my previous OnItemClick to <code>OnClickListener</code>.
I need the method to behave like my previous OnItemClick.</p>
<p>Because I need to declare some attributes like position, and id which aren't available in this method.</p>
<pre><code>convertView.setOnClickListener(new OnClickListener() {
public void onClick(View view) {
}
});
</code></pre>
<p>Therefore I need the <code>OnClickListener</code> method to behave like my previous <code>OnItemClick</code>.
Can anybody help me?</p>
<p>Thank you very much.</p>
| android | [4] |
4,827,424 | 4,827,425 | How to hide the source of a download on a webpage | <p>I'm looking for a way to hide the source of my download. I'm surprised this is not more covered, but it also makes me wonder whether it's possible.</p>
<p>(<strong>Edit:</strong> By hide I mean make it difficult or impossible for end user to find a direct link to the file. They will thus be forced to actually be on the page, clicking it, for it to work.)</p>
<p>I found a script to force download files that are locally stored. The way I see it, it hides the true source (at least it's not in view source or download history). </p>
<p><a href="http://w-shadow.com/blog/2007/08/12/how-to-force-file-download-with-php/" rel="nofollow">http://w-shadow.com/blog/2007/08/12/how-to-force-file-download-with-php/</a></p>
<p>So this works, I made it into a function that gets a linkID, and check that with a DB for the actual file-source. Hooray!</p>
<p>Only what if your downloads are on another server? Then you can't use most of the functions used here (like filesize, isreadable, fopen, ...). I'm not proficient enough to decide whether it is possible/feasible to make this work cross-server.</p>
<p>I realize that probably my webserver will lose bandwidth even though files aren't stored there, that's not a big issue. </p>
<p>Any info on the subject would be greatly appreciated. I prefer PHP, but I can work with whatever you give me, I really have no idea about this one.</p>
| php | [2] |
885,788 | 885,789 | How to select visible - on screen table rows in jQuery | <p>OK, I am stumped. I have an HTML table that is within a fixed height, scrollable div and I need to select (using jQuery) all table rows that are visible. That is all rows that are visible on screen. This will depend on where the user is currently scrolled to within the div. So, here is the HTML:</p>
<pre><code><div style="height:300px;overflow:auto">
<table id="mytable">
<tr><td>Row 1</td></tr>
<tr><td>Row 2</td></tr>
<tr><td>Row 3</td></tr>
<!-- 500 or so more rows here -->
</table>
</div>
</code></pre>
<p>Using a simple jQuery selector like below don't work because this selects all rows in the table because they are technically visible according to jQuery. They are just not actually visible because you have to scroll to see them.</p>
<pre><code>$('#mytable').find('tr').filter(':visible');
</code></pre>
<p>Instead, I need to see if anyone knows how to only select the rows that are visible within the scrollable div. That is only the rows that the user can actually see at any given point in time. If they scroll down and the selector is run again, it should return a different set of rows, those that are actually visible.</p>
<p>Hope I explained my question correctly. Let me know if I need to elaborate.</p>
| jquery | [5] |
1,432,814 | 1,432,815 | Printing a member of a previously added object into a linkedlist | <p>I am relatively new to java programming and i am currently trying to implement a Linked List in Java. I have a class called student. Which has the following members - Name, MarksObtained. Now, i want to add the various student objects to a linked list one by one.</p>
<blockquote>
<p>My_query1: Again, while traversing the list i want to print only the
member - MarksObtained. </p>
<p>My_query2: The iterator interface method,
itr.next() returns <strong><em>_</em>__<em>_</em>__<em>_</em>__<em>_</em></strong> ?</p>
<p>My_query3: If i create
objects of the class student with the same name iteratively and
simultaneously add it to the linked list, is it valid?</p>
</blockquote>
<pre><code>public static void main(String []args){
LinkedList al = new LinkedList();
for(int i=0; i<100; i++){
student s = new student();
s.MarksObtained = i;
s.Name = "blah";
al.add(s);
}
}
</code></pre>
<p>Thanks.</p>
| java | [1] |
2,136,955 | 2,136,956 | substr function in PHP5 | <p>I am developing an application were I need to use the next PHP5 code: </p>
<pre><code><?php
$Hurrengo_Hitza = 'word_3';
$Handiena_MarkID = 0;
$Handiena_Hitzarentzat = -2;
$Hitza_Index = substr($Hurrengo_Hitza , 5);
print $Handiena_MarkID . $Hitza_index . $Handiena_Hitzarentzat;
</code></pre>
<p>The result I am looking for is <code>0 3 -2</code> and the result I am getting is <code>0-2</code>. Which is the problem?</p>
| php | [2] |
4,005,397 | 4,005,398 | Android database access (simple and performant) | <p>I'm currently playing around with the android API. Currently I'm doing a bit of GUI-database binding and I'm starting to get a bit annoyed. </p>
<p>I have a simple <code>ListActivity</code> with a custom layout for the list items. Now I want to bind the underlying <code>ListView</code> to a table in the database. Whenever I make changes to the database I want to be able to notify the ListView to refresh itself and update the GUI. At first, the problem look straightforward: just add a <code>SimpleCursorAdapter</code>, pass it a cursor for fetching the data, bind columns to layout ids and your down. Whenever you want to do a refresh simply call <code>notifyDataSetChanged()</code> on the ListView and you are done, right? No!</p>
<p>Turns out, this way the database will be queried in the UI thread which is obviously a bad thing as it will degrade performance and could lead to "application not responding" errors.</p>
<p>Currently, it looks like the only way is to use Loaders and ContentProviders. This may be the most abstract and cleanest way to handle data access but it also adds a huge amount of code (especially in the ContentProvider itself where you have to do a lot of ugly if-else switch-case handling for "parsing" the requests). </p>
<p>So my question is: what is the state of the art (and backwards compatible to API level <11) way to connect a database table to a ListView (or any other UI components)? Do I really have to use a ContentProvider?</p>
<p>And why is this so complicated? I.e.: scanning for a bluetooth devices can be implemented in abaout 20 lines of code but for (from my perspective) much more common thing like data-ui-connection you have to implemented at least two classes which 100+ loc each. This is madness!</p>
| android | [4] |
5,533,510 | 5,533,511 | Android : Getting this error while downloading image from remote server: SkImageDecoder::Factory returned null | <p>I am trying to download images from a remote server, the number of images downloaded is 30. The code i am using to download image is as below. Some images download successfully and some images don't download and raises the above exception. What might be the problem.</p>
<pre><code>public static Bitmap loadBitmap(String url)
{
Bitmap bitmap = null;
InputStream in = null;
BufferedOutputStream out = null;
try {
in = new BufferedInputStream(new URL(url).openStream(), 4*1024);
final ByteArrayOutputStream dataStream = new ByteArrayOutputStream();
out = new BufferedOutputStream(dataStream, 4 * 1024);
int byte_;
while ((byte_ = in.read()) != -1)
out.write(byte_);
out.flush();
final byte[] data = dataStream.toByteArray();
BitmapFactory.Options options = new BitmapFactory.Options();
//options.inSampleSize = 1;
bitmap = BitmapFactory.decodeByteArray(data, 0, data.length,options);
} catch (IOException e) {
Log.e("","Could not load Bitmap from: " + url);
} finally {
try{
in.close();
out.close();
}catch( IOException e )
{
System.out.println(e);
}
}
return bitmap;
}
</code></pre>
| android | [4] |
960,920 | 960,921 | What Views Are Auto Saved on a Configuration Change | <p>On a configuration change, such as Screen Orientation Change, Android will automatically save some view information. For example, any text entered into an EditText will be saved and re-entered after the application is restarted. However, a TextView's text is not saved.</p>
<p>Does anyone have a list of Views that have data saved? And which values of each View?</p>
| android | [4] |
4,050,842 | 4,050,843 | How to get file from server | <p>I am doing Multimedia application using client server interaction, for that i uploaded some media files in apache tomcat server(My server is static). Now i want to display the media files whatever uploaded in sever to my android device (device is a client). I am confused how to get files from server to client. please guide me. give me some tutorials link. Note:i am using for multiple client. </p>
| android | [4] |
5,107,538 | 5,107,539 | Php - echo MySql column names and values | <p>What I need is to have a list name => value to be able to make MySql queries. My proble is, I can access MySql records, but I also need to access to the table column names, what should I change in my code?</p>
<p>Thanks</p>
<pre><code>$query = "SELECT * FROM test_table";
$result = mysql_query($query) or die("Erro!: " . mysql_error());
if (mysql_num_rows($result) > 0) {
$row = mysql_fetch_array($result);
if(is_array($row)) {
foreach ($row as $col => $val) {
echo $col." = ".$val."<br>";
}
}
}
</code></pre>
<p>ok, so now why can't I join the values to then make my sql queries?</p>
<pre><code>while($row = mysql_fetch_assoc($result)) {
foreach ($row as $col => $val) {
$colunas .= join(",",$col);
$valores .= join(",",$val);
}
echo "colunas = ".$col."<br>";
echo "valores = ".$val."<br>";
}
</code></pre>
<p>I just get empty colunas and valores</p>
<p>Thanks, sorry if it seems to easy, but I'm lost</p>
| php | [2] |
4,310,450 | 4,310,451 | how to set an icon for a python file | <p>I want to set an icon to a <strong>.py</strong> file . I dont want the default python icon to appear on the py file. Basically I want to set .ico image to the file.
Can you please tell me how to do it?</p>
<p>Thanks in advance.</p>
| python | [7] |
3,947,800 | 3,947,801 | How to show different clock from different time zones in iPhone app | <p>In my app I want to show timings of different countries like
Japan
UK
USA
France
how can I do that?</p>
| iphone | [8] |
3,507,092 | 3,507,093 | Fast conversion byte array to short array of audio data | <p>I need fastest way to convert byte array to short array of audio data.</p>
<p>Audio data byte array contains data from two audio channels placed in such way:</p>
<pre><code>C1C1C2C2 C1C1C2C2 C1C1C2C2 ...
where
C1C1 - two bytes of first channel
C2C2 - two bytes of second channel
</code></pre>
<p>Currently I use such algorithm, but I feel there is better way to perform this task.</p>
<pre><code>byte[] rawData = //from audio device
short[] shorts = new short[rawData.Length / 2];
short[] channel1 = new short[rawData.Length / 4];
short[] channel2 = new short[rawData.Length / 4];
System.Buffer.BlockCopy(rawData, 0, shorts, 0, rawData.Length);
for (int i = 0, j = 0; i < shorts.Length; i+=2, ++j)
{
channel1[j] = shorts[i];
channel2[j] = shorts[i+1];
}
</code></pre>
| c# | [0] |
555,677 | 555,678 | Adding an object to an array of objects with splice | <p>I have an array of objects that looks like this:</p>
<pre><code>event_id=[{"0":"e1"},{"0","e2"},{"0","e4"}];
</code></pre>
<p>How do I add an element to that array?</p>
<p>I thought of </p>
<pre><code>event_id.splice(1,0,{"0":"e5"});
</code></pre>
<p>Thanks.</p>
| javascript | [3] |
5,456,979 | 5,456,980 | Toggle effect not working in UL LI | <p>I have this menu item with a submenu. The submenu has five itens and I used jQuery to toggle it down. The problem is that only the first item of the submenu is toggling. Here's the code:</p>
<pre><code><script type="text/javascript">
$(document).ready(function () {
$("ul.menu-body li:even").addClass("alt");
$('img.menu-head').hover(function () {
$('ul.menu-body').slideToggle('slow');
});
});
</script>
<ul>
...
<li id="menu-03">
<a href="galeria_representacao.php?image=0"><img src="images/representacao.jpg" class="menu-head" onMouseOver="this.src='images/representacao-hover.jpg'" onMouseOut="this.src='images/representacao.jpg'" /></a>
<ul class="menu-body">
<li><a href="galeria_representacao.php?image=0">Dixtal</a></li>
<li><a href="galeria_philips.php?image=0">Philips</a></li>
<li><a href="galeria_biosensor.php?image=0">BioSensor</a></li>
<li><a href="galeria_biorad.php">BioRad</a></li>
<li><a href="galeria_leica.php?image=0">Leica</a></li>
</ul>
</li>
...
</ul>
</code></pre>
| jquery | [5] |
598,632 | 598,633 | Is there any way to exit the application when home button is pressed on Android? | <p>I want to kill the app when user presses the home button. Is there any way to do this on Android?</p>
| android | [4] |
208,540 | 208,541 | how to use process id given by one process into another process using c# | <p>Suppose there is a exe or process which finds process id of newly start process i have to use that pid in some other program but the main problem is that the process that finds pid has while(true ) loop. i.e infinite loop so i cant return any value from it. is there any solution .if yes then please help me.</p>
| c# | [0] |
2,474,135 | 2,474,136 | How to remove button from form element? (JavaScript) | <p>I have this html </p>
<pre><code><form id="form">
<input id="deleteNumber" name="del" type="hidden" />
<input id="addAddress" name="addAddress" type="hidden" />
...
...
...
<a href="javascript:deleteAddress();" class="deleteItem"/></a>
<a href="javascript:addNextAddress()">Add address </a>
</form>
<script type="text/javascript">
function addNextAddress() {
var parent = document.getElementById('form');
var child = document.getElementById('form').del;
perent.removeChild(child);
document.getElementById('form').submit();
}
</script>
<script type="text/javascript">
function deleteAddress() {
var r=confirm(text);
if (r == true) {
var parent = document.getElementById('form');
var child = document.getElementById('form').addAddress;
perent.removeChild(child);
document.getElementById('form').submit();
}
}
</script>
</code></pre>
<p>I get js error:</p>
<blockquote>
<p>Uncaught ReferenceError: perent is not
defined</p>
</blockquote>
<p>Can anybody help?</p>
| javascript | [3] |
1,115,947 | 1,115,948 | Application is disappearing | <p>I have an app to track the car .App is going smoothly but suddenly it disappeared and again i have to restart the app from icon, Please tell me the reason for the disappearing of application .Thanks in advance</p>
| android | [4] |
1,858,015 | 1,858,016 | In python when passing arguments what does ** before an argument do? | <blockquote>
<p><strong>Possible Duplicate:</strong><br />
<a href="http://stackoverflow.com/questions/287085/what-does-args-and-kwargs-mean">What does *args and **kwargs mean?</a> </p>
</blockquote>
<p>From reading this example and from my slim knowledge of Python it must be a shortcut for converting an array to a dictionary or something?</p>
<pre><code>class hello:
def GET(self, name):
return render.hello(name=name)
# Another way:
#return render.hello(**locals())
</code></pre>
| python | [7] |
6,021,322 | 6,021,323 | php get static url and get section of url | <p>How do you get the routed url that is static, when I use $_SERVER["PHPSELF"] it returns that actual page of the url like for e.g</p>
<pre><code>/show_products.php
</code></pre>
<p>but the url I have is this</p>
<pre><code>http://mysite.com/browse/department/?pid=1&order_by=a_z&filter=1
</code></pre>
<p>what I want to get from the url is just this</p>
<pre><code> http://mysite.com/browse/department/
</code></pre>
<p>and also I would like to be able to just get the department section of the url so there is two parts to my question</p>
| php | [2] |
4,434,224 | 4,434,225 | how to select text with the jquery-select-event inside a div element? | <p>is it possible to throw the jquery-select() event on a text which is inside a div element?
here is my example but it doesnt work.</p>
<pre><code><div id='id1'>Hello text</div>
$("#id1").select( function () {
alert("something was selected");
});
</code></pre>
<p>My goal is to select a word in a text and to put this selected word in an URL and to open a new window with this url.
For example i mark or rather i select the word hello, the word hello should apear in this url</p>
<pre><code>window.open('http://dict.leo.org/ende?lp=ende&lang=de&searchLoc=0&cmpType=relaxed&sectHdr=on&spellToler=&search=Hello');
</code></pre>
<p>i am not sure if the select-event is the right way.
please help.
sorry for my bad english!</p>
| jquery | [5] |
1,570,788 | 1,570,789 | make typedefs incompatible | <p>Situation:</p>
<pre><code>typedef int TypeA;
typedef int TypeB;
</code></pre>
<p>I need to make TypeA incompatible with TypeB (so any attempt to assign TypeA to TypeB would trigger compile error), while retaining all functionality provided by built-in type (operators). </p>
<p>One way to do it is to wrap each type into separate struct/class (and redefine all operators, etc).</p>
<p>Is there any other, more "elegant", way to do it?</p>
<p>Third party libraries are not allowed. C++0x/C++11x is not supported. (C++ 2003 is supported)</p>
| c++ | [6] |
2,710,639 | 2,710,640 | Get the first jquery element in a deep search and break traversal | <p>Is it possible to force jquery <code>find()</code> to only return the first matched element and not the childs of that element. Something that would be called "nearest"...</p>
| jquery | [5] |
4,321,028 | 4,321,029 | Is there a way to embed dependencies within a python script? | <p>I have a simple script that has a dependency on <a href="http://pypi.python.org/pypi/dnspython/" rel="nofollow">dnspython</a> for parsing zone files. I would like to distribute this script as a single .py that users can run just so long as they have 2.6/2.7 installed. I don't want to have the user install dependencies site-wide as there might be conflicts with existing packages/versions, nor do I want them to muck around with virtualenv. I was wondering if there was a way to embed a package like dnspython inside the script (gzip/base64) and have that script access that package at runtime. Perhaps unpack it into a dir in /tmp and add that to sys.path? I'm not concerned about startup overhead, I just want a single .py w/ all dependencies included that I can distribute.</p>
<p>Also, there would be no C dependencies to build, only pure python packages.</p>
<p>Edit: The script doesn't have to be a .py. Just so long as it is a single executable file.</p>
| python | [7] |
4,086,218 | 4,086,219 | How to convert string formula to a mathematical formula in C# | <p>If I have a string variable with a formula:</p>
<pre><code>string myformula = "3 * 5 + Pow(2,3)";
</code></pre>
<p>How can I convert this string to a mathematical formula that the compiler can calculate?</p>
| c# | [0] |
3,160,998 | 3,160,999 | Javascript Reccurrency picker | <p>Is there a Javascript library which makes it possible to choose from every hour of the day and have options like Every work day, only on weekends etc. Or Every sunday 19:00.</p>
| javascript | [3] |
3,174,431 | 3,174,432 | OOP PHP - Returning $connection from functions (please see code) | <p>Procedural PHP works for me, but when I try to code like I do in objective C I cannot seem to get the functions to work. I think it has something to do with my variable scope and the functions not returning any values. Where am I going wrong with my code here?</p>
<pre><code> <?php
require_once("constants.php");
class Main {
public $menu;
public $connection;
function connectToDatabase() {
//connect to database & check connection
$connection = mysqli_connect(DB_SERVER, DB_USER, DB_PASS, DB_NAME);
if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); }
}
function queryDatabase($select, $from) {
$result = mysqli_query($connection,"SELECT $select FROM $from");
}
function closeDatabaseConnection() {
mysqli_close($connection);
}
function displayMenu() {
//connect to database & check connection
connectToDatabase();
//get menu data
queryDatabase(*, pages);
//construct menu data
echo '<ul class="mainNavigation">';
while($row = mysqli_fetch_array($result))
{
echo '<li><a href="' . $row['filename'] . '.php">';
echo $row['menu_name'];
echo '</a></li>';
}
echo '</ul>';
//close connection
closeDatabaseConnection();
}
function displayFooter() {
}
function getUser() {
}
function userLogIn() {
}
}
?>
</code></pre>
| php | [2] |
2,870,521 | 2,870,522 | Passing options to Python executable in non-interactive mode | <p>I would like to pass some options to Python (version 2.6) every time, not just in interactive mode. Is there a file I can put such commands in?</p>
<p>EDIT: Specifically, I'm wanting to silence the Deprecation warnings.</p>
| python | [7] |
5,354,553 | 5,354,554 | is there an api for word meaning or dicitonary? | <p>I have an app that checks the spelling entered by the user. What i am trying to do is when user corrects there spelling it shows them the complete meaning of the word. Is there any free api i can use to do this? With no limitations? </p>
<p>Also i tried finding a dictionary with meaning that i can upload to my server which will have over 200k words and all the meanings in it. But i am unable to find any. Have anyone here used a dictionary like this that you can refer me to?</p>
<p>I looked at this:</p>
<p><a href="http://stackoverflow.com/questions/1255731/english-dictionary-sql-dump">English dictionary SQL dump?</a>
but these also dont have meanings with them</p>
| php | [2] |
3,428,280 | 3,428,281 | Maintain same session in html5/jquery | <p>I had a HTML5 + Jquery code to send HTTP POST to server to retrieve the data. First of all, Client apps need to perform login through Jquery + json. Then, client need to use the same session to call the web services to retrieve the data.</p>
<p>Can anyone advice me/ provide me an example on how to maintain/store session using js/jquery and html5 only? </p>
<p>Thanks in advance for the help.</p>
| jquery | [5] |
3,436,635 | 3,436,636 | File private variables in PHP | <p>Is it possible to define private variables in a PHP script so these variables are only visible in this single PHP script and nowhere else? I want to have an include file which does something without polluting the global namespace. It must work with PHP 5.2 so PHP namespaces are not an option. And no OOP is used here so I'm not searching for private class members. I'm searching for "somewhat-global" variables which are global in the current script but nowhere else.</p>
<p>In C I could do it with the <em>static</em> keyword but is there something similar in PHP?</p>
<p>Here is a short example of a "common.php" script:</p>
<pre><code>$dir = dirname(__FILE__);
set_include_path($dir . PATH_SEPARATOR . get_include_path());
// Do more stuff with the $dir variable
</code></pre>
<p>When I include this file in some script then the $dir variable is visible in all other scripts as well and I don't want that. So how can I prevent this?</p>
| php | [2] |
2,791,988 | 2,791,989 | Force popup window ratio on resize | <p>I know there maybe ugly hacks to achieve this, which is why I am asking this. Basically I have a video chat window, so I want to allow resizing of window, but I would like to force the ratio (so that it is maintained). I guess I can run a javascript which refreshes every X seconds and resizes the window. </p>
<p>Any good ideas? I don't mind if the hacks work on certain browsers and not on others. As many as possible.</p>
| javascript | [3] |
3,083,175 | 3,083,176 | Jquery Validation OnBlur of textbox | <p>Javascript: </p>
<pre><code><script type="text/javascript">
function checkdata() {
$("#TextBoxesGroup :input").each(function () {
if (!$(this).val()) {
alert(this.val()+":Dis");
$("#addButton").attr("disabled", "disabled");
}
else {
alert(this.val() + ":Ena");
$("#addButton").removeAttr("disabled");
}
});
}
$(document).ready(function () {
$("#addButton").attr("disabled", "disabled");
$("#TextBoxesGroup :input").each(function () {
$(this).blur(function () {
checkdata();
});
});
});
</script>
</code></pre>
<p>Html</p>
<pre><code><div id='TextBoxesGroup'>
<div style="float: left; width: 625px;">
<div>
<input type="text" name="answer" class="ahsan" />
</div>
</div>
</div>
<div style="clear: both;">
</div>
<div>
<input type="button" value="Add New Row" class="qa-adbtn" id='addButton' />
</div>
</code></pre>
<p>Now the thing i want to do is that if user enter something in textbox(ahsan) .then add button enabled and if there is nothing in textbox onblur then add button automatically goes disabled</p>
| jquery | [5] |
2,608,217 | 2,608,218 | Checking if 2 arrays have atleast 1 equal value | <p>Currently I have 2 array:</p>
<pre><code>array(1, 2, 3, 4);
array(4, 5, 6, 7);
</code></pre>
<p>How can I check if there is atleast one equal value in both of them? (The example above has 1 equal value => 4, so the function should return true).</p>
| php | [2] |
714,417 | 714,418 | Or statement isn't functioning properly | <p>I want to be redirected if I don't have an account1 or if I don't have an account2. The problem is, even if I have account1 it is redirecting me:</p>
<pre><code>if(($_SESSION['account'] != "account1") || ($_SESSION['account'] != "account2")){
header("location:/home");
exit();
}
</code></pre>
<p>It works properly and doesn't redirect me when I have account1 when I don't include the OR:</p>
<pre><code>if($_SESSION['account'] != "account1"){
header("location:/home");
exit();
}
</code></pre>
<p>but I also need it to not redirect if they, by chance, have account2.</p>
<p>What am I doing wrong?</p>
| php | [2] |
3,353,949 | 3,353,950 | Initialising Arrays and Objects: using brackets or 'new'? | <p>When initialising Arrays and Objects in JavaScript, is there any difference between these two statements: </p>
<pre><code>var a = [];
var a = new Array();
</code></pre>
<p>or between these two statements: </p>
<pre><code>var b = {};
var b = new Object();
</code></pre>
<p>If there is a difference, which is to be preferred?</p>
<p>Thanks!</p>
| javascript | [3] |
3,269,257 | 3,269,258 | How to install older versions of Android via the SDK Manager? | <p>I downloaded the Android SDK from <a href="http://developer.android.com/sdk/index.html" rel="nofollow">here</a>, as suggested by all tutorials.</p>
<p>I downloaded Android v4.0.3 (API 15) via the SDK manager, but it won't allow me to download older SDK/API versions, e.g 2.2?</p>
<p>I found <a href="http://stackoverflow.com/questions/11278534/android-how-to-install-older-api-versions">this Stack question</a>, but when i try and download one of the packages, it just 404s.</p>
<p>I have a single repository setup in the SDK Manager:</p>
<p><a href="https://dl-ssl.google.com/android/repository/repository.xml" rel="nofollow">https://dl-ssl.google.com/android/repository/repository.xml</a></p>
<p>What am i doing wrong?</p>
| android | [4] |
2,984,966 | 2,984,967 | How to include GET & POST data in PHP error log | <p>Is there a way to have <code>PHP</code> log errors to a file or email me errors <code>INCLUDING $_POST[]</code> & <code>$_GET[]</code> and <code>$_SERVER[]</code> data?</p>
<p>Right now I get a log of <code>PHP FATAL</code> and <code>WARNING</code> errors and <code>404 NOT_FOUND</code> errors but it's hard to debug some errors without knowing things like user input and the referrer.</p>
<p>Thanks</p>
| php | [2] |
2,278,210 | 2,278,211 | how to replicate parts of code in python into C to execution faster? | <p>i have prepared a project in python language ie a TEXT TO SPEECH synthesizer. Which took a total on 1500 lines of code.
But there few parts of code due to which it is taking so much time to run the code, i want to replace that parts of code in C/c++ lang so that it runs faster.</p>
<p>So i want to know how can i run these parts of code in C++ or improve its speed in any other way??</p>
<p>please suggest,</p>
| python | [7] |
3,295,934 | 3,295,935 | Jquery version for $("#submit").on("click", function(){ | <p>Does anybody know when </p>
<pre><code> $("#submit").on("click", function(){
</code></pre>
<p>came out. Meaning what version of Jquery started using the .on()</p>
| jquery | [5] |
5,921,708 | 5,921,709 | error (1, -2147483648) on Android | <p>Does anybody know the meaning of this error?</p>
<pre><code> VideoView video = (VideoView) findViewById(R.id.myvideo);
Intent videoint=getIntent();
String url = videoint.getStringExtra("url"); //The url pointing to the mp4
video.setVideoPath(url);
video.requestFocus();
video.setMediaController(new MediaController(this));
video.start();
</code></pre>
| android | [4] |
4,298,815 | 4,298,816 | how to read two txt files in c++ | <p>I want to read two matrices from two different txt files, and say output them in another one.
I doesn't write all of them, it only writes the fist one and "Hi" and stops there.
So I believe it cannot read the second file.
Here is the code:</p>
<pre><code>#include <iostream>
#include <fstream>
using namespace std;
#define I 5
#define J 5
#define P 2
int i,j,k; //for loops
int main ()
{
ifstream inFile;
ofstream outFile;
double C[I][J];
double u[I][J];
double UB = 0;
outFile.open("results.txt");
// READ U0
inFile.open("u.txt", ios::in);
if (! inFile) {
cerr << "unable to open file u.txt for reading" << endl;
return 1;
}
for(i = 0; i < I; i++)
for(j = 0; j < J; j++)
inFile >> u[i][j];
outFile << "u" << endl;
for(i = 0; i < I; i++)
{
for(j = 0; j < J; j++)
outFile << u[i][j];
outFile << endl;
}
outFile << "Hi";
//READ C
inFile.open("C.txt", ios::in);
if (! inFile) {
cerr << "unable to open file C.txt for reading" << endl;
return 1;
}
for(i = 0; i < I; i++)
for(j = 0; j < J; j++)
inFile >> C[i][j];
outFile << "C" << endl;
outFile << "UB=" << UB;
inFile.close();
outFile.close();
return 0;
}
</code></pre>
| c++ | [6] |
5,486,302 | 5,486,303 | Python - How to store a socket and a username in a list? | <p>Is there any way I can store a socket and a username in a list? I don't think this is possible, as an integer is required in the list to store the index. What would you guys recommend I do? Really have no idea.</p>
| python | [7] |
4,822,245 | 4,822,246 | How would I get the name of a higher directory in PHP? | <p>For example, I'm working on a script to check various settings and permissions. It checks <code>../login/includes/</code> to see if it's writeable, but when it displays an error, I would like to display the full URL to it.</p>
<p>For example, the URL to the installer would be <code>http://example.com/path/to/installer/index.php</code> and when it errors I would like it to display <code>http://example.com/path/to/login/includes/</code> rather than <code>http://example.com/path/to/installer/../login/includes/</code></p>
<p>I'm aware I can use <code>$_SERVER['HTTP_HOST']</code> to get the <code>example.com</code> but I need to know how to get the <code>path/to/</code></p>
<p>Any ideas?</p>
| php | [2] |
1,072,818 | 1,072,819 | How to load .java file to compiler? | <p>Ok, I am beginner in JAVA. I have just started. I downloaded Java SE Development Kit 6u21 and wrote a program, saved it in .java and try to run it, but I can not do it. What's wrong? Thank you.</p>
| java | [1] |
26,337 | 26,338 | how to Search a particular string in the followings tweets of twitter using twitter api in asp.net? | <p>Is there a functionality to search for particular string in the tweets on twitter ????</p>
<p>kindly help me out..</p>
| asp.net | [9] |
3,981,691 | 3,981,692 | Possible Recursion issue, event conflict: Can't set .droppable() and .draggable() to the same selector, | <p>so I have found that when I add both <code>.draggable()</code> and <code>.droppable()</code> to an element. (in this case, an image) that it won't work. The <code>.droppable().over:</code> code never fires. </p>
<p>it is probably due to some recursion I use to move my images, but I can't figure out why its breaking.</p>
<p>I have found out whats broken, and split out the problem domain into a .jsFiddle</p>
<p>I'm thinking I have some kind of event conflict going on with setting the .droppable() code. It can be 'fixed' by commenting out the 'over' event in the top <code>.droppable()</code></p>
<p><strong>well I <em>need</em> that 'over' event to do some work</strong>, hence, my problem.</p>
<p>in the code in the fiddle, you see 2 pawns on some chess squares. hovering one pawn over another should make an alert pop up, but only works when you comment out the "over" event in the top (spot) droppable:</p>
<p><a href="http://jsfiddle.net/KevinGabbert/jBQby/60/" rel="nofollow">http://jsfiddle.net/KevinGabbert/jBQby/60/</a></p>
<p>Success means that you pick up one pawn, and hover it over the other. an alert will pop up telling you the ID of the pawn being hovered OVER. (I already have a workaround, but I need to know why the 'over' event isn't working, and how to structure my code to make it work)</p>
<p><strong>I am not looking for a workaround. I am looking to for the answer that makes the 'over' code work</strong></p>
| jquery | [5] |
2,897,733 | 2,897,734 | Testing command line parameters | <p>What is the best way to test a command line parameter from within the Visual Studio C# Express 2010 IDE? All i see is the "Play" button to start debugging (and running) my program.</p>
| c# | [0] |
3,669,576 | 3,669,577 | RegisterForContextMenu ImageView? | <p>I'm trying to use a floating context menu and I wonder if it's possible to activate this menu, by pressing the image in the ImageView?</p>
<p>My first problem is how to handle registerForContextMenu and the ImageView? I searched and find most examples with GridView and ListViews.</p>
<p>I have made the menu in xml and I should I use this method in the activity with a switch:</p>
<pre><code> @Override
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenuInfo menuInfo) {
// TODO Auto-generated method stub
super.onCreateContextMenu(menu, v, menuInfo);
}
</code></pre>
| android | [4] |
4,810,103 | 4,810,104 | How can I group a sequence by two values and keep the order of the sequence? | <p>Let's say I have a list of Points.</p>
<pre><code>{(0,0), (0,0), (0,1), (0,0), (0,0), (0,0), (2,1), (4,1), (0,1), (0,1)}
</code></pre>
<p>How can I group this Points, so that all Points with the same x- and y-value are in one group, till the next element has other values?</p>
<p>The final sequence should look like this (a group of points is enclosed with brackets):</p>
<pre><code>{(0,0), (0,0)},
{(0,1)},
{(0,0), (0,0), (0,0)},
{(2,1)},
{(4,1)},
{(0,1), (0,1)}
</code></pre>
<p>Note that the order has to be exactly the same.</p>
| c# | [0] |
2,076,172 | 2,076,173 | I need to replace a C# switch with something more compact | <p>I have the following code:</p>
<pre><code>switch (pk.Substring(2, 2))
{
case "00":
ViewBag.Type = _reference.Get("14", model.Type).Value;
break;
case "01":
ViewBag.Type = _reference.Get("18", model.Type).Value;
break;
}
</code></pre>
<p>It does the job but does not look very clean to me. Is there some way I could make this code a bit smaller. I was thinking to just have the number 14 or 18 as a variable but I am not sure the best way to code if I should use if-else or some other way.</p>
| c# | [0] |
3,811,373 | 3,811,374 | Fetching data from Internet in background and showing ProgressDialog or ProgressBar | <p>I am developing an application which require accessing a website for
data, and will show that data on device. I wants to fetch data from
Internet in background and show ProgressDialog or ProgressBar on
device and when application receive response from server app will
dismiss the dialog or bar and will show data .</p>
<p>For this i am using AsyncTask -</p>
<p>code for AsyncTask is as follows--</p>
<pre><code>ServerTask extends AsyncTask {
@Override
protected void onPreExecute() {
dialogAccessingServer = new ProgressDialog(ctx);
dialogAccessingServer.setMessage(shownOnProgressDialog);
dialogAccessingSpurstone.show();
}
@Override
protected ServerResponse doInBackground(String... urlArray) {
String urlString = urlArray[0];
HttpResponse serverResponseObject = null;
//finding HttpResponse
return serverResponseObject;
}//end of doInBackground
@Override
protected void onPostExecute(HttpResponse serverResponseObject){
dialogAccessingSpurstone.dismiss();
}
}
</code></pre>
<p>and calling this code as follows--</p>
<pre><code>ServerTask serverTaskObject = new ServerTask();
serverTaskObject.execute();
HttpResponse response = serverTaskObject.get();
</code></pre>
<p>//performing operation on response</p>
<p>but ProgressDialog is not shown.(I guess the reason for it is the
thread is not complete and android invalidate only when thread has
completed).</p>
<p>My Questions --
1- If my guess is right ? If yes then how I should implement it?
2- If there is any other better way to do this?</p>
<p>thanks </p>
| android | [4] |
5,827,666 | 5,827,667 | evrytime i create a uri object as new Uri("some uri") , it says as uri cannot instantiate....ny othesolution is there? | <p>Uri u = new Uri("content://contacts")</p>
| android | [4] |
1,810,811 | 1,810,812 | Possible to terminate a class? | <p>I've got a program which runs multiple classes. I'd like a class to stop executing if a condition is true and NOT execute the rest of the code without killing the other classes. This class runs on it's own thread. is this do-able?</p>
<pre><code> class A{
private void method{
if(condition == true){
//terminate class
}
}
}
</code></pre>
| java | [1] |
407,903 | 407,904 | java: how to manipulate data array in main class? | <p>This is called <code>GoHomeAction.java</code></p>
<pre><code>import javax.swing.*;
import java.awt.Image;
import java.awt.event.ActionEvent;
import static java.awt.event.KeyEvent.VK_H;
public class GoHomeAction extends BrowserAction {
public GoHomeAction(BrowsersTabbedPane controller) {
}
public void actionPerformed(ActionEvent e) {
//need to add to data[] which is located in MainClass.java
}
}
</code></pre>
<p>in this action, I need to add to the <code>data[]</code> which is located in one of the functions inside <code>MainClass.java</code></p>
<p>how can I achieve this ?</p>
| java | [1] |
1,293,761 | 1,293,762 | What are the basic and important things I have to learn as a iPhone application developer? | <p>I am new to iPhone applications. What are the important things(concepts) i have to concentrate to develop iPhone applications. </p>
| iphone | [8] |
2,406,656 | 2,406,657 | Avoiding bad habits on ASP.NET 2.0 Web Forms | <p>I'll be starting my first web development job in a few weeks. Most of the code I'll be working on will be ASP.NET 2.0/3.5 Web Forms. What bad habits does this platform lend itself to and how should I avoid succumbing to them? </p>
| asp.net | [9] |
2,695,344 | 2,695,345 | In ASP.NET, how can I keep login state for two weeks? | <p>I make a website and upload it to a shared hosting. I use default ASP.NET Login control to login, but sometimes I have to require login again even if I have checked "Remember me next time".
I hope I can access member webpage during two weeks without login, how can I do that? Thanks!</p>
<pre><code><%@ Page Language="C#" AutoEventWireup="false" CodeFile="Default2.aspx.vb" Inherits="Default2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Login ID="Login1" runat="server">
</asp:Login>
</div>
</form>
</body>
</html>
<membership>
<providers>
<clear/>
<add name="AspNetSqlMembershipProvider"
type="System.Web.Security.SqlMembershipProvider"
connectionStringName="MyConnect"
enablePasswordRetrieval="false"
enablePasswordReset="true"
requiresUniqueEmail="true"
maxInvalidPasswordAttempts="10"
minRequiredPasswordLength="1"
minRequiredNonalphanumericCharacters="0"
passwordAttemptWindow="10"
applicationName="/"
requiresQuestionAndAnswer="true"
/>
</providers>
</membership>
</code></pre>
| asp.net | [9] |
5,679,859 | 5,679,860 | Android Annotations.jar | <p>While creating a new android project annotations.jar is automatically added in android dependency.Can anyone please tell me whats the use of this jar.If needed we can add separately but why it is added itself.</p>
<p>Thanks in advance</p>
| android | [4] |
827,424 | 827,425 | elegant way to print "==== middle justified title ====" in python | <p>As I know, there are some elegant ways to print left and right justified string with filling.
like this</p>
<pre><code>str = "left_justified"
str.ljust(20, '0');
</code></pre>
<p>or</p>
<pre><code>print "{0:{1}<20}".format(str, "=")
</code></pre>
<p>result will be</p>
<pre><code>left_justified=====
</code></pre>
<p>what is the best way to print middle-justified string with filling</p>
| python | [7] |
3,688,017 | 3,688,018 | How can I get the Return value of onBeforeUnload | <p>I want to do a certain action based on, what the user clicks due to onbeforeunload event. For ex, if the user clicks on "stay on current page" then do some action, else do something else.</p>
<p>I am not getting anyway to fetch the return value of onbeforeunload and do some action based on that. </p>
<p>Any help will be appreciated.</p>
| javascript | [3] |
6,007,096 | 6,007,097 | Error in inserting statement when inserting | <p>I am working on c# project and using winform. </p>
<p>Here the problem is the query was working previously but now it is not working </p>
<p>Here the <code>todaydate</code> is a <code>datetimePicker</code> which is set to short date format
and my datatype of column is <code>smalldatetime</code> the error i am getting is</p>
<pre><code> The conversion of a nvarchar data type to a
smalldatetime data type resulted in an out-of-range value.
The statement has been terminated.
</code></pre>
<p>if i have two date time picker one for date and second for time then how can i insert? please can you guide me</p>
| c# | [0] |
981,209 | 981,210 | Pointer to a typedef with incomplete type | <p>Is there any way to declare a pointer to an incomplete type that will be set by a typedef in the implementation?</p>
<p>Here is exemple of what I want:</p>
<pre><code>#ifndef TEST_H
#define TEST_H
namespace std {
class string; // THIS WON'T WORK!
}
struct Test {
std::string *value;
};
#endif
</code></pre>
<p>string is a typedef to basic_string, so the code in the exemple won't work. I could declare an incomplete type of std::basic_string, but thats looks like a workaround.</p>
<p>I know that the compiler won't generate symbols for typedefs, and it could happen that the same name could be used in typedefs for different types in different files. But since a pointer is a pointer (at least to the compiler), it should be possible to do something like that.</p>
<p><strong>EDIT</strong>: This is just a minimalist working exemple. In my real problem, I have a Facade which uses a class from a library that only the Facade should need to know (no, it's not std::string, and the library is not stl). I'm not really worried with circular inclusion, but since a lot of files in my project include this Facade (directly or indirectly), I am worried with compile time, so I want to include the library file only in the Facade's implementation file.</p>
| c++ | [6] |
2,546,651 | 2,546,652 | java send mail on Linux: Error certification | <p>I try to send mail by Java on Linux server.
I setup to run on Tomcat 6, config SSL
but I got an error message: </p>
<pre><code> Can't send command to SMTP host
javax.mail.MessagingException: Can't send command to SMTP host;
nested exception is: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
</code></pre>
<p>My java code like below:</p>
<pre><code> String host = "smtp.gmail.com";
int port = 587;
String username = "java.test@gmail.com";
String password = "aabbcc";
Properties props = new Properties();
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.starttls.enable", "true");
Session session = Session.getInstance(props);
try {
Message message = new MimeMessage(session);
message.setFrom(new InternetAddress("java.test@gmail.com"));
message.setRecipients(Message.RecipientType.TO,
InternetAddress.parse("test504@gmail.com"));
message.setSubject("Testing Subject");
message.setText("Dear Mail Crawler," +
"\n\n No spam to my email, please!");
Transport transport = session.getTransport("smtp");
transport.connect(host, port, username, password);
Transport.send(message);
System.out.println("Done");
} catch (MessagingException e) {
System.out.println("ERROR: "+e.getMessage());
System.out.println("ERROR: "+e.toString());
throw new RuntimeException(e);
}
</code></pre>
<p>If I config Tomcat without SSL -> It can send mail Success
But within SSL -> I have above error</p>
<p>Please help fix error. Thank guys!</p>
| java | [1] |
663,428 | 663,429 | How to access web camera settings (like in Skype) using DotNet | <p>In my application I need to access my web Camera settings.
I saw that Skype calling to the camera's settings application.
Does anyone know how to do this?
I am using C#/WPF/dotNet 4 framework.</p>
<p>Thanks</p>
| c# | [0] |
5,250,007 | 5,250,008 | Redefining python list | <p>is it possible to redefine the behavior of a Python List from Python, I mean, without having to write anything in the Python sourcecode?</p>
| python | [7] |
5,165,103 | 5,165,104 | Java and Unix corroboration | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/525212/how-to-run-unix-shell-script-from-java-code">How to run Unix shell script from java code?</a> </p>
</blockquote>
<p>I'm creating a web application with spring mvc, which will be multi-user app. Each user will create own configurations etc etc.</p>
<p>When all configuration is done they should start building and running their project from the web app(executing a shell script from java), today I stumbled upon this post while googling </p>
<p><a href="http://stackoverflow.com/questions/525212/how-to-run-unix-shell-script-from-java-code/525222#525222">How to run Unix shell script from java code?</a></p>
<p>What is your opinion on this, is there a better way to do this other than <code>Runtime.getRuntime()</code> ...</p>
| java | [1] |
672,400 | 672,401 | C++ dynamic binding | <p>How can C++ achieve dynamic binding yet also static typing?</p>
| c++ | [6] |
3,342,462 | 3,342,463 | Hiding/Showing Status Bar | <p>I'm developing an iPhone app that switches from a table view to a landscape fullscreen view (similar to the YouTube app). When it does so, I want to hide the status bar, then display it again when switching back to the table view. I'm using setStatusBarHidden but that just seems to hide the status bar wihout enlarging the screen area; there's still a blank bar where the status bar was. If set the hidden status bar property in Info.plist then I get the enlarged screen area but when the status bar displays it overlays the view.</p>
<p>How do I hide the status bar in such a way that the full screen is available to my view when it's hidden and only the screen under the status bar when it's displayed?</p>
<p>TIA. </p>
<p>Craig </p>
<p>PS: I copy/edit this question from app discussion. do not find good solution
<a href="http://discussions.apple.com/thread.jspa?threadID=1580662&start=15&tstart=0">http://discussions.apple.com/thread.jspa?threadID=1580662&start=15&tstart=0</a></p>
| iphone | [8] |
2,881,514 | 2,881,515 | Online PPT Viewer with all power point support | <p>I am looking to develop online ppt viewer which supports all the feature of MS Power Point, I searched all the sites but did not find any good work. So I tried to convert ppt to xps and then show that xps in xps viewer, but xps viewer does not support all the feature of ms power point.
can you guide me how to show ppt file online with all MS Power Point features?</p>
| asp.net | [9] |
5,843,197 | 5,843,198 | JTable problem | <p>I have one panel which i am adding to dialog from some othere frame.
But my problem is, i want to close the jdialog when user presses "Enter", </p>
<p>For Example,</p>
<p>from frame-1 i am calling and adding the panel which contains table to the dialog from this frame,</p>
<pre><code> /* Frame_1*/
JDialog jd = new JDialog();
jd.add(panel1); // This panel comes from another java file Frame_2 which contains JTable and retruns Panel
</code></pre>
<p>So i want is that when user press "Enter" i want this dialog to be disposed, but the focus goes to table, and the code for listeners is in Frame_2 for JTable. and i dont know how to do dispose in Frame_2 for JDialog ??</p>
| java | [1] |
232,565 | 232,566 | software buttons height | <p>How I can calculate height of software buttons (like in galaxy nexus or razr motorola hd) ?</p>
<p>Personally, I suppose that <code>DisplayMetrics.heightPixels</code> attribute is height of all screen without software buttons height and with height of status bar.</p>
<p>Hence, <strong>software buttons height</strong> = <strong>specification height</strong> - <strong>DisplayMetrics.heightPixels</strong>.</p>
<p>Exemple for nexus 7:</p>
<p><code>75(soft button height) = 1280(spec height) - 1205(DisplayMetrics.heightPixels)</code></p>
<p>Im right ? please confirm. </p>
| android | [4] |
2,027,188 | 2,027,189 | C++ Variable Conversion | <p>I need to pass one of my parameters to a write() function. It is asking for a type of 'const void*' I am a PHP guy and don't know C++ very well. </p>
<p>Here is my parameter:</p>
<pre><code>const fmx::Text& distance = dataVect.AtAsText(3);
</code></pre>
<p>I don't know of any other way to pull in that field. I would love to just declare it const void* but I don't know how. </p>
<p>I guess just converting it would be easier than trying to pull it in the correct way??</p>
<p>The error message: cannot convert const fmx::Text to const void* for argument 2</p>
<pre><code>write(fd, distance, 4);
</code></pre>
<p>I know this worked so can I just convert?</p>
<pre><code>const void* s = "5000";
</code></pre>
<p>This is for a plugin in FileMaker so I don't really get c++ here.</p>
<p>Is there more anyone would need to help me solve this??</p>
<p>Thanks so much! </p>
| c++ | [6] |
2,909,495 | 2,909,496 | IndexError: list assignment index out of range | <pre><code>class Packagings:
def __init__(self):
self.length=0
self.deckle=0
self.tmp=0
self.flute=[]
self.gsm=[]
self.t_weight=0
self.weight=0
def read_values(self):
print """Select Type Of Paper
1.3 Ply
2.5 Ply
3.7 Ply
"""
self.type=input("Enter the type:")
self.l=input("Enter Length:")
self.b=input("Enter Breadth:")
self.h=input("Enter Height:")
self.flap=input("Enter Flap:")
def ply_read_values(self):
for i in range(0,2):
self.flute[i]=input("Enter flute:")
self.gsm[i]=input("Enter Gsm:")
self.weight[i]=self.tmp*(flute[i]*gsm[i])
self.t_weight=self.t_weight+self.weight[i]
def do_calc(self):
self.length=(2*self.l+2*self.b+self.flap)/1000
self.deckle=(float(self.h+self.b))/1000
self.tmp=self.length*self.deckle
def print_value(self):
print self.length
print self.deckle
print self.t_weight
#Main Function
obj=Packagings()
obj.read_values()
obj.do_calc()
obj.ply_read_values()
obj.print_value()
</code></pre>
<p>When I run this program, I get the following error. I cannot find how the list assignment goes out of range. Could you guys go through my program and tell me where I went wrong? For me the list seems fine. How does it go out of index?</p>
<pre><code>Traceback (most recent call last):
File "C:/Python27/packagings.py", line 47, in <module>
obj.ply_read_values()
File "C:/Python27/packagings.py", line 27, in ply_read_values
self.flute[i]=input("Enter flute:")
IndexError: list assignment index out of range
</code></pre>
| python | [7] |
4,609,505 | 4,609,506 | What does new() mean in this case? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/4236854/c-what-does-new-mean">C#: What does new() mean?</a> </p>
</blockquote>
<p>I look at definition of Enum.TryParse:</p>
<pre><code>public static bool TryParse<TEnum>(string value, out TEnum result) where TEnum : struct, new();
</code></pre>
<p>and wondering what <code>new()</code> means here.</p>
| c# | [0] |
12,638 | 12,639 | what kind of parser is NSXMLParser | <p>what kind of parser is NSXMLParser.?</p>
<p>Is it dom parser or sax parser.</p>
<p>how many parsers are there?</p>
| iphone | [8] |
850,227 | 850,228 | PHP date function date range | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/8717861/php-see-if-date-range-is-partly-within-another-date-range">PHP, see if date range is partly within another date range</a> </p>
</blockquote>
<p>I have 2 dates, a start date (2011-01-01) and an end date (2011-02-28).</p>
<p>I have a third date that starts on 2010-01-01 and ends on 2012-03-01. This means that this third date falls within the first 2 dates range.</p>
<p>If the third dates start and/or end date is not within the 2 dates then it must be false. </p>
<p>How can I check this using php? </p>
| php | [2] |
2,254,439 | 2,254,440 | How do I extract the first part of a url? | <p>Given:</p>
<pre><code>http://something.com:4567/data/21/28/188
</code></pre>
<p>How do I get only the following with JavaScript?</p>
<pre><code>http://something.com:4567/
</code></pre>
| javascript | [3] |
2,099,829 | 2,099,830 | JavaScript - Is it possible to view all currently scheduled timeouts? | <p>So I was wondering, is there any feasible way in JavaScript to view information about scheduled timeouts and intervals that you don't explicitly know about (I know <code>setTimeout</code> and <code>setInterval</code> return a handle that can be used to refer to the scheduled instance, but say that this is unavailable for one reason or another)? For instance, is there a way to use a tool like Chrome's JavaScript console to determine what timeouts are currently active on an arbitrary page, when they will fire, and what code will be executed when they fire? More specifically, say a page has just executed the following JavaScript:</p>
<pre><code>setTimeout("alert('test');", 30000);
</code></pre>
<p>Is there some code I can execute at this point that will tell me that the browser will execute <code>alert('test');</code> 30 seconds from now?</p>
<p>It seems like there theoretically should be some way to get this information since pretty much everything in JavaScript is exposed as a publicly accessible property if you know where to look, but I can't recall an instance of ever doing this myself or seeing it done by someone else.</p>
| javascript | [3] |
777,175 | 777,176 | Getting ready for Android Playstore | <p>I have a question, If I want to upload my Android App to Market and have it not display in the Play Store until ready to go live can I do that, Something like reserve the name and game style until ready to release.</p>
| android | [4] |
4,040,151 | 4,040,152 | Writing my own split method | <p>I found out earlier today that split() doesn't work if attached to a single value.
I would like to write my own split() method so that if I sent it a single value, it creates an array with a single value.</p>
<p>Q: Should I change the split prototype or write a function?</p>
<pre><code>var SPLIT=function(X) {
return X.toString().split()
}
</code></pre>
| javascript | [3] |
2,739,384 | 2,739,385 | C# - Task Exception not being caught | <p>I am sure I am doinig something wrong, but when I try this example of the new threading task exception handling I keep getting the exception unhandled by user code. The whole point of the code is to show an example of how to catch errors in tasks. </p>
<p>Link: <a href="http://msdn.microsoft.com/en-us/library/dd997415.aspx" rel="nofollow">Task Exception Example</a></p>
<pre><code>static void Main(string[] args)
{
var task1 = Task.Factory.StartNew(() =>
{
throw new MyCustomException("I'm bad, but not too bad!");
});
try
{
task1.Wait();
}
catch (AggregateException ae)
{
// Assume we know what's going on with this particular exception.
// Rethrow anything else. AggregateException.Handle provides
// another way to express this. See later example.
foreach (var e in ae.InnerExceptions)
{
if (e is MyCustomException)
{
Console.WriteLine(e.Message);
}
else
{
throw;
}
}
}
}
</code></pre>
<p>Most likely user error just not sure what (Using Visual Studio 2012);</p>
| c# | [0] |
931,430 | 931,431 | Why doesn't this menu toggle? | <p>On my site (<a href="http://test.tamarawobben.nl" rel="nofollow">http://test.tamarawobben.nl</a>) I use an accordion menu. When I choose the 2005 option and after that 2006, 2005 stays open though I was expecting it would close.</p>
<p>Can anyone give me a hint why this happens and how to fix it?</p>
<p>Roelof</p>
| javascript | [3] |
4,351,917 | 4,351,918 | Parsing a text file, handling a new line? | <p>I'm trying to write a simple program which takes a textfile, sets all characters to lowercase and removes all punctuation. My problem is that when there is a carriage return (I believe that's what it is called) and a new line, the space is removed.</p>
<p>i.e.</p>
<blockquote>
<p>This is a<br>
test sentence</p>
</blockquote>
<p>Becomes</p>
<blockquote>
<p>This is atestsentence</p>
</blockquote>
<p>The last word of the first line and the first word of the next line are joined.</p>
<p>This is my code:</p>
<pre><code>public static void ParseDocument(String FilePath, String title)
{
StreamReader reader = new StreamReader(FilePath);
StreamWriter writer = new StreamWriter("C:/Users/Matt/Documents/"+title+".txt");
int i;
char previous=' ';
while ((i = reader.Read())>-1)
{
char c = Convert.ToChar(i);
if (Char.IsLetter(c) | ((c==' ') & reader.Peek()!=' ') | ((c==' ') & (previous!=' ')))
{
c = Char.ToLower(c);
writer.Write(c);
}
previous = c;
}
reader.Close();
writer.Close();
}
</code></pre>
<p>It's a simple problem, but I can't think of a way of checking for a new line to insert a space. Any help is greatly appreciated.</p>
| c# | [0] |
4,518,743 | 4,518,744 | Android how to show 50% transparent of a non-selected image in a galery view? (selected will be 100%) | <p>Android how to show 50% transparent of a non-selected image in a
galery view? (selected will be 100%)</p>
<p>Thanks,
Leslie</p>
| android | [4] |
3,841,914 | 3,841,915 | Image to byte array from a url | <p>I have a hyperlink which has a image, i need to read/load the image from that hyperlink & assign it to a byte array (byte[]) in C#</p>
<p>Thanks.</p>
| c# | [0] |
5,259,812 | 5,259,813 | show PIN screen when user clicks HOME button android | <p>I have an Android application that consists of several activities that are available to the user behind a login acitivity. What I want to do is to show a PIN/login activity when the user hits the HOME button (from any of the activities) and then subsequently returns to the application. Effectively, what I'd like to do is to log out the user when the HOME button is clicked.</p>
<p>From reading other posts, it's my understanding that there is no way to handle the HOME button click directly using a key click event handler. I have tried adding an intent filter for the CATEGORY_HOME intent in the activities:</p>
<pre><code>@Override
public void onCreate( Bundle savedInstanceState ) {
IntentFilter homeIntentFilter = new IntentFilter();
homeIntentFilter.addCategory( Intent.CATEGORY_HOME );
BroadcastReceiver homeReceiver = new BroadcastReceiver() {
@Override
public void onReceive( Context context, Intent intent ) {
showHomeToast();
}
};
registerReceiver( homeReceiver, homeIntentFilter);
}
public void showHomeToast() {
Toast homeToast = Toast.makeText( this, "home clicked", Toast.LENGTH_LONG );
homeToast.show();
}
</code></pre>
<p>But this doesn't seem to fire.</p>
<p>Additionally, since there are many activities in the application, triggering a logout in the onPause or onStop events seems problematic since they will fire when the user is simply switching to other activities in the application - and in that case, the user should not be logged out of the application. (also, from experimentation, onDestroy will not be invoked simply by hitting thing HOME button)</p>
<p>At this point, I feel like I'm fighting the Android architecture, so I'm looking for an alternate approach. I have contemplated trying to invert my approach and to use the onResume event, but again I'm unclear how to know whether a given activity is being resumed from another activity in the application (no PIN/login necessary) or because the user has invoked the application again.</p>
<p>Any approaches would be appreciated.</p>
| android | [4] |
5,048,117 | 5,048,118 | How to know unique identifier of SD/memory Card in Android? | <p>I would like to know the way to find the unique identifier (generally a unique string of 11 characters has been assigned to each memory card) in Android programatically.
Please help me by giving some tips/suggestions to get the same.</p>
| android | [4] |
2,551,518 | 2,551,519 | How to add a touch listener to a surface view? | <p>I am new to Android, so please excuse if it is asked before!</p>
<p>I am playing with some camera code (found online) and I want to show/hide some buttons on screen. When the user touches the screen, I want it to capture the image. </p>
<p>My setup:</p>
<p>1.
Main Activity:</p>
<pre><code>public class CameraDemo extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_inuse);
preview = new Preview(this);
((FrameLayout) findViewById(R.id.preview)).addView(preview);
... ...
// rest of the code that captures the image when a button is pressed.
// the button is defined in main.xml with button id ButtonClicked
}
</code></pre>
<p>2.
The preview class looks like this:</p>
<pre><code>class Preview extends SurfaceView implements SurfaceHolder.Callback {
SurfaceHolder mHolder;
public Camera camera;
Preview(Context context) {
super(context);
// Install a SurfaceHolder.Callback so we get notified when the
// underlying surface is created and destroyed.
mHolder = getHolder();
mHolder.addCallback(this);
mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
}
</code></pre>
<p>My question is,</p>
<ol>
<li><p>How can I add touch functionality so that the user can touch the preview (say for a second, or just touch quickly) and something happens ? (Say image is saved)</p></li>
<li><p>And a button will appear on the surface say a "Next" button, for example?</p></li>
</ol>
| android | [4] |
1,950,737 | 1,950,738 | how to remove stop words in english using java program | <p>How to remove stop words in english using java program. Please help me with simplest program or suggest me some ideas. Thanks in advance</p>
| java | [1] |
2,997,086 | 2,997,087 | How to get datakeys value in a gridview | <p>I try to delete a record in Gridview and Database .I added a boundfield button and set the CommandName to <strong>Deleterecord</strong> in the RowCommand event I want to get the primary key of this record to delete that(primary key value does not show in the grid view. The following block of code shows this event(I try to show some data in a text box):</p>
<pre><code>protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Deleterecord")
{
TextBox1.Text = GridView1.DataKeys[GridView1.SelectedIndex].Value.ToString();
//bla bla
}
}
</code></pre>
<p>I also set </p>
<pre><code>DataKeyName="sourceName"
</code></pre>
<p>in the gridview but it is not my primary key</p>
<p>If I click this button an exception occured like this:
<strong>Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index</strong>
How can I solve this problem</p>
| asp.net | [9] |
4,736,039 | 4,736,040 | Save gps-location to sqlite continuously | <p>I'm trying to make my own gps-tracker, mainly for bike-rides. I managed to make a usable app, at least for personal use, but I wanted to improve it, and have added ContentProviders, Fragments, CursorAdapters and a Service to receive the onLocationChanges from GPS.</p>
<p>However, I have really no idea how to handle the stream of Locations I'm receiving. My old app just saved them to an ArrayList, so right now my Service is sending a Broadcast to my Activity, that saves them to the ArrayList.</p>
<p>Problem is, that when the ride is over, it takes from 5-15 seconds to save the locations to sqlite (yes, I'm using compiledstatement and transaction), and I would like to avoid that, by saving the locations when received. When I tried to do that, my app became unresponsive (as expected), as I was doing the insert in the UI thread, and I do receive location updates often.</p>
<p>This is of course the most important aspect of the app, so what is the solution?</p>
<ul>
<li><p>I could do the insert in a thread, but since inserting a single record is expensive, I'm not sure it could keep up.</p></li>
<li><p>I could write 25 records (or more) at a time in a transaction, but there will be some logic to keep track of what is saved and what is not.</p></li>
</ul>
<p>Is there other options for a better user-experience ?</p>
| android | [4] |
1,086,053 | 1,086,054 | Android Alarm with user specified alarm tone | <p>what I want to do is that I have stored date and time in a database and the Id of alarm tone I want to play the specific tone on specific time and date as chosen by the user inspite of my efforts couldn't find anything like that please help.. </p>
<p>Thanks in advance
Aashish</p>
| android | [4] |
5,455,657 | 5,455,658 | optimized memcpy | <p>Are there faster alternatives to memcpy() in C++? </p>
| c++ | [6] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.