Unnamed: 0 int64 65 6.03M | Id int64 66 6.03M | Title stringlengths 10 191 | input stringlengths 23 4.18k | output stringclasses 10 values | Tag_Number stringclasses 10 values |
|---|---|---|---|---|---|
3,040,583 | 3,040,584 | comparing dates in c# taking null value into account | <p>I am new to c#. I am comparing two dates where one is entered by user and the other one is sytem date time. i have the code working as it stands where the obstacle has occured is how to cater for null values. the basic code I have is:</p>
<pre><code>if (mydate.ToShortDateString() != TodaysDate.ToShortDateString())
{
//Error Messaage
}
else
{
//do some code
}
</code></pre>
<p>Any feedback will be appreciated</p>
| c# | [0] |
4,537,171 | 4,537,172 | String: replace a line which contains a word | <p>I have a string copied from a mutiline text box. I am looking for a method to replace the whole line which contains a specific phrase.
For example the string looks like this:</p>
<pre><code>Lorem ipsum dolor sit amet,
consectetur adipiscing elit.
Suspendisse egestas.
</code></pre>
<p>So I would like to find a method to replace the whole line that contains for example phrase <code>elit</code> with the new line <code>enim vehicula pellentesque.</code> so the resoult would be: </p>
<pre><code>Lorem ipsum dolor sit amet,
enim vehicula pellentesque.
Suspendisse egestas.
</code></pre>
<p>Is there a quick way to do it?</p>
<p>Thanks</p>
| c# | [0] |
2,937,390 | 2,937,391 | Java Reserve Keywords | <p>Are <code>generic</code>, <code>cast</code>, and <code>threadsafe</code> reserved keywords in java?
I am aware of the 52 keywords in java but looking for the new reserved keyword list.</p>
| java | [1] |
6,027,111 | 6,027,112 | Asp.net - what are the best latest tools /frameworks, etc to look at . . | <p>Ok, i have done a bunch of asp as well as asp.net right when it came out. A friend is starting a non profit organization and he wants me to put together a site for him. I figured i would kill 2 birds with one stone and look to freshen up my skills on the latest that the web has to offer in asp.net, web 2.0, etc.</p>
<p>The site requirements are pretty simple:</p>
<ol>
<li>Organization mission statement</li>
<li>Users ability to register</li>
<li>Photos, content</li>
<li>Blog posts</li>
<li>Ability to donate directly on the site (maybe through paypal)</li>
</ol>
<p>So my questions is what are the best tools to start here given its going to be hosted on windows ASP.net platform 3.5. Any other frameworks that i should be looking at. </p>
<p>Where is the best place to start?</p>
<p>I could easily build the site just putting a table together and a bunch of static pages but i figured if it made sense to utilize and help freshen my skills, it would be worth the efforts of the learning curve. </p>
<p>Feel free to suggest any other items that i haven't listed.</p>
| asp.net | [9] |
5,050,258 | 5,050,259 | How do you dynamically create a radio button in Javascript that works in all browsers? | <p>Dynamically creating a radio button using eg </p>
<pre><code>var radioInput = document.createElement('input');
radioInput.setAttribute('type', 'radio');
radioInput.setAttribute('name', name);
</code></pre>
<p>works in Firefox but not in IE. Why not?</p>
| javascript | [3] |
4,044,156 | 4,044,157 | Is it possible to link container to other one? | <p>I have an array of data. I have put this data on my site in different places over different attributes, how innerHTML value placeholder etc.
Is it possible to link this values with the array from where I can take data? So that when I change the data in array, it going automatic changed on the site?
Also I try to show how I did it mean:</p>
<pre><code>var test = Array();
test['place1'] = 'NY';
var myspan = document.createElement('span');
myspan.innerHTML = test['place1'];
</code></pre>
<p>On some event the value of <code>test['place1']</code> is changed to <code>'LA'</code>, and at the same moment the value of <code>myspan.innerHTML</code> must be changed too.</p>
<p>Native JS only please.</p>
| javascript | [3] |
1,482,371 | 1,482,372 | strncmp in python | <p>I am parsing through a file with a list of paths. I am trying to see if one path is under a specific directory or not. So I have two strings S1 and S2. Lets say they are
S1 = '/tmp/' and S2 = '/tmp/file.txt'</p>
<p>If I want to check if is S2 has S1 and then some extra bytes in C, I would do a strncmp of S1 and S2 upto strlen(S1) bytes. Is there a way to do that in python? I am new to python and do not know all the modules available to me yet. I could implement this trivially by just iterating over the characters in the strings and comparing, but want to find out if there is anything that gives me these kind of helper functions by default</p>
<p>Thanks for any help. </p>
<p>P</p>
| python | [7] |
3,757,471 | 3,757,472 | rookie PHP question, what does -> represent? | <p>I am a rookie with PHP, what does this do ->? i tried Google and searching the forums but nothing came up. for instance, i have seen "$resp->is_valid" used but not sure what it does. Thanks</p>
| php | [2] |
2,319,775 | 2,319,776 | Registration program | <p>I am trying to make a simple registration program and I cant seem to make it where when a user would register, the information would be saved and so when they log in, there account would be already registered. And for some reason the <code>("Password: ")</code> won't come up.? By the way, it will be an offline registration so could I use a .txt file or something for the database?</p>
<pre><code>username = raw_input("Create a new username: ")
password = raw_input("Create a password: ")
firstname = raw_input("What's your first name?: ")
lastname = raw_input("What's your last name?: ")
phonenumber = raw_input("Enter your phone number.: ")
print "Thank you for signing up!"
signin = raw_input("Username: ")("Password: ")
</code></pre>
| python | [7] |
917,080 | 917,081 | Python delete in a string | <p>I have these 3 string:</p>
<p>YELLOW,SMALL,STRETCH,ADULT,T21fdsfdsfs</p>
<p>YELLOW,SMALL,STRETCH,ADULT,Tdsfs</p>
<p>YELLOW,SMALL,STRETCH,ADULT,TD</p>
<p>I would like to remove everything after the last "," including the comma. So i want to remove these parts ",T21fdsfdsfs" ",Tdsfs" and "TD". How could i do that in Python?</p>
<p>Thanks</p>
| python | [7] |
405,997 | 405,998 | Unable to run gridview.databind(), eventargs error | <p>I have a listbox, that on selected change, runs a method to bind data to a gridview. I get the error: <strong>Unable to cast object of type 'System.EventArgs' to type 'System.Web.UI.WebControls.GridViewRowEventArgs'</strong>. I have other parts of my code that call another gridview.databind() from other controls, so I have no idea why it's throwing this error now? </p>
<pre><code>Protected Sub lstEmployees_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles lstEmployees.SelectedIndexChanged
Dim x As Int16
Dim startStr, endStr As String
If txtAdminSelectedDate.Text <> "" Then
dtWeeks = GetWeek(txtAdminSelectedDate.Text)
End If
If dtWeeks.Rows.Count > 0 Then
x = dtWeeks.Rows(0).Item(0).ToString().IndexOf("-")
endStr = dtWeeks.Rows(0).Item(0).ToString().Substring(x + 1, 11)
startStr = dtWeeks.Rows(0).Item(1).ToString()
dtWrkHours = GetHoursOfTheWeek(startStr, endStr, _user).Tables(0)
gvAdmin.DataSource = dtWrkHours
gvAdmin.DataBind()
sStatus = String.Empty
aStatus = String.Empty
AdminTot = 0
timeTot = 0
End If
End Sub
</code></pre>
| asp.net | [9] |
962,637 | 962,638 | javascript learn | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/11246/best-resources-to-learn-javascript">Best resources to learn JavaScript</a> </p>
</blockquote>
<p>I am looking for manuals or books for learning javascript. I need learn basic behaviors of the language (e.g. data types) and extended behaviors (e.g. work with DOM or cross-browsing programming). Where to start?</p>
| javascript | [3] |
3,996,642 | 3,996,643 | Applying class to an element - JQuery | <p>I am working on a web page that has a large number of tables. The JQuery script processes each row and decides what CSS style needs to be applied to it. I am using this snippet to apply a class to the table cell</p>
<pre><code>$myElem.parents('td').eq(0).attr('class', 'requiredClass');
</code></pre>
<p>Functionally, it works as expected. However, in IE7.0, it takes 16ms to run this. Given the number of rows on the page, this adds up pretty quickly to atleast half a second.</p>
<p>How can I make this run faster?</p>
| jquery | [5] |
1,812,287 | 1,812,288 | Mysql Insert Into Error | <p>I've created a registration form and I'm adding the data with php but for some reason it will not let me add the data into the database. Can you see anything wrong with this code?</p>
<pre><code><?php
mysql_connect("localhost", "root", "password") or die("No Connection");;
mysql_select_db("music") or die("No Database");;
$username= mysql_real_escape_string($_REQUEST["username"]);
$password= mysql_real_escape_string($_REQUEST["password"]);
$email= mysql_real_escape_string($_REQUEST["email"]);
$hash = md5( rand(0,1000) );
mysql_query("INSERT INTO members (id, username, password, email, hash, active) VALUES('', '$username', '$password', '$email', '$hash', '')") or die("Can't Add");
if(mysql_affected_rows()>0){
echo "1";
}else{
echo "2";
}
?>
</code></pre>
<p>I Keep getting a Can't Add error indicating that there is a simple problem with the mysql_query row</p>
<p>Thank you</p>
| php | [2] |
3,143,503 | 3,143,504 | Getting NullPointerException in onpostexecute method | <p>Problem is in onpostexecute method</p>
<pre><code>@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
contactListView = getListView();
contactListView.setOnItemClickListener(viewContactListener);
String[] from = new String[]{"name"};
int[] to = new int[]{R.id.contactTextView};
@SuppressWarnings("deprecation")
CursorAdapter contactAdapter = new SimpleCursorAdapter(AddressBook.this,
R.layout.contact_list_item, null, from, to);
setListAdapter(contactAdapter);
}
@Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
new GetContactsTask().execute((Object[])null);
}
@SuppressWarnings("deprecation")
@Override
protected void onStop() {
// TODO Auto-generated method stub
Cursor cursor = contactAdapter.getCursor();
if(cursor != null)
cursor.deactivate();
contactAdapter.changeCursor(null);
super.onStop();
}
private class GetContactsTask extends AsyncTask<Object, Object, Cursor>{
DatabaseConnector databaseConnector = DatabaseConnector(AddressBook.this);
@Override
protected Cursor doInBackground(Object... params) {
// TODO Auto-generated method stub
databaseConnector.open();
return databaseConnector.getAllContacts();
}
@Override
protected void onPostExecute(Cursor result) {
contactAdapter.changeCursor(result);
databaseConnector.close();
}
}
</code></pre>
| android | [4] |
5,001,013 | 5,001,014 | Where to put bitmaps for Nexus7? | <p>Specs for Nexus7 is 7-inch screen, 1280 x 800 resolution and 216 pixels-per-inch.
I made drawable-xlarge-hdpi folder and put image in that folder.
But when I check bitmap size, I get smaller size than actual size.
What is wrong?
I tried drawable-large-hdpi, but the result is the same.</p>
<pre><code>image = BitmapFactory.decodeResource(res, R.drawable.image);
int width = image.getWidth(); // this returns smaller than actual size.
</code></pre>
| android | [4] |
4,052,433 | 4,052,434 | How to run a PHP function concurrently against an array? | <p>I have a PHP web app which scrapes a search engine for a given keyword.</p>
<p>Currently the app is looping through an array of keywords running the scrape function one keyword at a time.</p>
<p>This is OK at the moment because the number of keywords is fairly small, but it won't scale well.</p>
<p>I think the best way to go will be to select a smaller set of keywords from the mysql db using limit, and then run the scrape function concurrently against the entire array. Once that set has finished, I'll move on to the next set.</p>
<p>But I'm stuck with how to run the function concurrently against the array.</p>
<p>How would you handle this?</p>
| php | [2] |
1,804,530 | 1,804,531 | python stdout carriage return | <p>i am running a for loop on a given set of files..and for monitoring purpose it writes output on which files are being currently processed..</p>
<pre><code>sys.stdout.write("\rProcessing.... "+ j)
sys.stdout.flush()
</code></pre>
<p>where j is filenames</p>
<p>output of script...</p>
<pre><code>Processing.... /etc/sysconfig/rhn/sources0.examplewn-slepcsbals-ipv6f
</code></pre>
<p>problem is that the carriage return "\r" does not clear the previous filename clearly and has previous filenames on it.</p>
<p>any idea how i can fix this..and make it more clear</p>
| python | [7] |
2,455,064 | 2,455,065 | What can I do with my old iPhone | <p>I currently use my iPhone 3G for testing my apps, but I am thinking about upgrading to the iPhone 4. What can I do to my 3G so I can still use it for testing. I don't need it to have 3G access, I just want to be able to put apps on it for performance testing since it is a slower device. I would still like to keep Wi-Fi access if possible. What options do I have?</p>
| iphone | [8] |
1,708,009 | 1,708,010 | MK802 - Android 4.0 Mini PC - not listed with 'adb devices' command - how to install my app | <p>I recently purchased the MK802; Android 4.0 Mini PC. However, I am unable to install the apps I developed. I have tried using the 'adb devices' command but the device does not appear on the list. I have also downloaded the Andorid 4.0 SDK (the version used in th MK802) on my computer but still no luck. I also made sure to enable 'USB Debugging' and 'Unknown Sources' in the device settings.</p>
<p>I realize I can load my app from an SD card (but I would have to buy one); or that I can download my app onto the device by making it available on a server or the android marketplace but these options seem like too much effort just to install an app.</p>
<p>Any suggestions or recommendations would be greatly appreciated. </p>
| android | [4] |
2,099,682 | 2,099,683 | Starting Application Again from MAIN & Clearing the activity stack | <p>I have developed an android 2.1 application which consumes Soap Web Service.
When my application gets started, it first checks whether there is internet connectivity or not.</p>
<p>If so, it will display corresponding activity.
If not then it will display an Activity(NetworkErrorActivity) giving information about network errors and all.</p>
<p>The problem is if there is no internet connectivity, it shows me the NetworkErrorActivity.
Now when user presses back button it redirects the user to Home.
I have overriden onBackPressed method like this :</p>
<p>@Override
public void onBackPressed() {</p>
<pre><code> Intent setIntent = new Intent(Intent.ACTION_MAIN);
setIntent.addCategory(Intent.CATEGORY_HOME);
setIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(setIntent);
return;
}
</code></pre>
<p>After pressing back button, it shows me the android home screen.
But the problem is when i start the same application again, it shows me the NetworkErrorActivity even if there is network connectivity. Could not start the application from Main Launcher Activity. It always shows me the same Activity again and again.</p>
| android | [4] |
4,756,356 | 4,756,357 | Setting the object to null without passing it as ref | <p>What's C# language specification for the following behavior. The values of the attributes are retained but the new instance (either null or new object) isn't updated to the actual parameter. It's basically functions as ref except changing the object it points to.</p>
<p>The object in the main function remained intact (not null) but the string attribute has been changed to "Hello World"</p>
<pre><code>class Program
{
class MyClass
{
public string str;
}
static void MyMethod(MyClass obj)
{
obj.str = "Hello World";
obj = null;
}
static void Main(string[] args)
{
MyClass o = new MyClass();
o.str = "Hello";
Console.WriteLine(o.str);
MyMethod(o);
Console.WriteLine(o.str); // prints "Hello World"
}
}
</code></pre>
| c# | [0] |
4,952,282 | 4,952,283 | how to set up the listener for SimpleAdapter | <p>I have created a list/table sorts with the following code.</p>
<pre><code>ListView list = (ListView) findViewById(R.id.list1);
btn = (Button) findViewById(R.id.btTaken);
ArrayList<HashMap<String, String>> mylist = new ArrayList<HashMap<String, String>>();
HashMap<String, String> map = new HashMap<String, String>();
String Date;
//list.setOnItemSelectedListener((OnItemSelectedListener) this);
// list.setOnItemClickListener(ListItemClick);
// cb.setVisibility();
Date=AttendanceDao.Dates()[0];
for(i=0;i<AttendanceDao.Dates().length;i++)
{
map = new HashMap<String, String>();
map.put("Date", AttendanceDao.Dates()[i]);
//map.put("StudentName",Data.Sname()[i]);
mylist.add(map);
}
// ...
SimpleAdapter mSchedule = new SimpleAdapter(this, mylist, R.layout.att_date_list,
AttendanceDao.Datemap(), new int[] {R.id.Sid});
list.setAdapter(mSchedule);
</code></pre>
<p>This part of the code</p>
<pre><code> protected void onListItemClick(ListView l, View v, int position, long id) {//this guy is not working!
// TODO Auto-generated method stub
Intent openActivity = new Intent("net.vrixx.activities.ATTENDANCELISTACTIVITY");
startActivity(openActivity);
}
</code></pre>
<p>is supposed to listen to the item clicked on my list. But it doesnt work Can anyone figure out why? thanks!</p>
| android | [4] |
3,108,891 | 3,108,892 | PHP Nested Loop - Comparing each item in two arrays and outputting them as checked or unchecked textboxes | <p>I think the title explains most of it. The items of the two arrays that I know are matching strings do not come out as checked checkboxes. What I have:</p>
<p>*Edit: realized I was using the wrong array. However, now I'm only getting the first entry right because of th breaks. </p>
<pre><code><?php
foreach ($list as $x){
foreach ($arr as $y){
if ($x == $y){
echo '<li>';
echo '<input type="checkbox" checked="checked" value="'.$x.'" />'.$x.'<br/>';
echo '</li>';
break;
}
else {
echo '<li>';
echo '<input type="checkbox" value="'.$x.'" />'.$x.'<br/>';
echo '</li>';
break;
}
}
}
echo '</ul>';
?>
</code></pre>
| php | [2] |
3,571,135 | 3,571,136 | Define a temporary dir under www to upload files | <p>I'm trying to upload a file to the apache public_html directory.
Well I believe it deserves to mention that I'm on a virtual hosting environment running on a VPS with a few domains and sub-domains.</p>
<p>Usually on my XAMPP server I wouldn't have any problems loading files to temporary folder but on the new server It's impossible it gives me an error when trying to upload.</p>
<p>I've checked the superglobal $_FILES and I get this error:</p>
<pre><code>array(1) { ["file"]=> array(5) { ["name"]=> string(9) "test.gif" ["type"]=> string(0) "" ["tmp_name"]=> string(0) "" ["error"]=> int(1) ["size"]=> int(0) } }
</code></pre>
<p>I've tried to set a tmp folder on the server with get_init('/tmp') without any success.</p>
<p>Thank you very much for your kind attention.</p>
| php | [2] |
628,918 | 628,919 | Jquery lazyload plugin and callback function | <p>i download jquery lazyload plugin from this site <a href="http://www.appelsiini.net/projects/lazyload" rel="nofollow">http://www.appelsiini.net/projects/lazyload</a>.</p>
<p>from their doc i have not found that one can use any callback or not with lazyload plugin.</p>
<p>suppose my html look like</p>
<pre><code><div id="gallery" class="busy"><img src="blah.jpg" /></div>
<div id="gallery" class="busy"><img src="blah2.jpg" /></div>
<div id="gallery" class="busy"><img src="blah3.jpg" /></div>
</code></pre>
<p>my script like</p>
<pre><code>$("#gallery img").lazyload();
</code></pre>
<p>class busy will just set a busy image at the center of div. so i need a callback and from the callback i need to detect image download completed or not if completed then i just remove the class from corresponding parent div of image tag .</p>
<p>so please show me the way to implement callback with lazyload and also need sample code by which i can remove the class from corresponding parent div of image tag .</p>
<p>thanks</p>
| jquery | [5] |
2,520,982 | 2,520,983 | In adb shell, how to use/ access ioctl command | <p>In adb shell, I want to know how to use/access ioctl command, I need proper usage/example</p>
<p>Any Help, Appreciated ....</p>
| android | [4] |
1,089,297 | 1,089,298 | Flash animation in Android device | <p>Can we run a flash animation inserting the .html, .swf and .fla files in the assets folder to run flash animation in Android device?Is it possible? Thank you</p>
| android | [4] |
2,463,904 | 2,463,905 | How to get each Bar CGMutablePathRef in Bar chart created by using Core Plot? | <p>I found below method in existing framework. Can any one please suggest me how can i use this method</p>
<p>-(CGMutablePathRef)newBarPathWithContext:(CGContextRef)context recordIndex:(NSUInteger)index</p>
<p>Thanks in advance</p>
| iphone | [8] |
341,257 | 341,258 | DrawThemeBackground to bitmap | <p>I am trying to use DrawThemeBackground to draw to a bitmap in C#, but it always comes out as black.</p>
<pre><code>Bitmap bmp = new Bitmap(this.Width, this.Height, PixelFormat.Format32bppArgb);
using (Graphics g = Graphics.FromImage(bmp))
{
g.Clear(Color.Green);
IntPtr hdc = g.GetHdc();
DrawThemeBackground(hTheme, hdc, 0, 1, ref rect, IntPtr.Zero);
g.ReleaseHdc(hdc);
}
</code></pre>
<p>It appears that DrawThemeBackground isn't looking at the background colour of the bitmap (green in this case) and is always blending with black. Am I missing something here? Is this even possible to do?</p>
| c# | [0] |
1,541,062 | 1,541,063 | Can the C# using statement be written without the curly braces? | <p>I was browsing a coworkers c# code today and found the following:</p>
<pre><code> using (MemoryStream data1 = new MemoryStream())
using (MemoryStream data2 = new MemoryStream())
{
// Lots of code..........
}
</code></pre>
<p>I had always seen the <code>using</code> statement followed by a pair of curly braces that defined the scope of the object life. My coworker who wrote the code said that the curly braces for the <code>data1</code> <code>using</code> statement weren't needed and the code did the same thing as if they were present and nested the <code>data2</code> <code>using</code> statement. So, what happens when the curly braces are ommitted?</p>
| c# | [0] |
799,023 | 799,024 | How to get android 2.3.4 sourcecode? | <p>Exactly the android 2.3.4's sourcecode. Anyone can help me?</p>
<p>I have got the android2.3.3's sourcecode,any one know how to update it to 2.3.4?</p>
<p>I don't want to download the whole sourcecode. - -</p>
| android | [4] |
1,410,999 | 1,411,000 | How to get all the pictures from the sdcard of emulator and display it in a listView? | <p>I have a folder called images in the sdcard of my emulator. This folder contains pictures clicked from my application. I want to display all the pictures from that folder to a listview. How can i do that? Thanks in advance.</p>
| android | [4] |
5,576,928 | 5,576,929 | Finding Week, using current date ? In C#? | <p>In C# how can i find the week of the current date, i am trying to get the week number of the current date, can you help me, thank you.</p>
| c# | [0] |
3,893,794 | 3,893,795 | Brainstorm dynamic process flow with php | <p>I'm wondering if you can help me get started with a project, if there is already something else out there (in any language) that is opensource that I can study the code that would be great.</p>
<p>What I want to do is create a process flow like this: <a href="http://www.ifitjams.com/starting.htm#starting%200" rel="nofollow">http://www.ifitjams.com/starting.htm#starting%200</a> and then have the app 'learn' from its users if the outcome works or if it doesn't to dynamically create the next process from there input. So in the car example above they could say after ending the process flow at 'x' it didn't work but I changed the alternator and it worked. So when the next person comes along and reaches point 'x' instead of the system running out of ideas it can suggest to change the alternator.</p>
<p>Just finding it hard to map out how I would have this app work and interact with a database to achieve this.</p>
| php | [2] |
180,307 | 180,308 | Format decimal that represents hour into HH:mm | <p>I'm trying formatting a Double that represents hour like this:</p>
<pre><code>Double totalHours = 1.05;
int hour = totalHours.intValue();
Long minutes = Math.round((totalHours - hour) * 60);
System.out.println(hour + ":" + minutes);
</code></pre>
<p>In this case I get <code>"1:3"</code> but I wold like <code>"01:03"</code>. How would I do this?</p>
<p>Or there's a better way to do this?</p>
| java | [1] |
90,796 | 90,797 | Java method reference | <p>I've some class with these methods:</p>
<pre><code>public class TestClass
{
public void method1()
{
// this method will be used for consuming MyClass1
}
public void method2()
{
// this method will be used for consuming MyClass2
}
}
</code></pre>
<p>and classes:</p>
<pre><code>public class MyClass1
{
}
public class MyClass2
{
}
</code></pre>
<p>and I want <code>HashMap<Class<?>, "question"></code> where I would store (key: class, value: method) pairs like this ( class "type" is associated with method )</p>
<pre><code>hashmp.add(Myclass1.class, "question");
</code></pre>
<p>and I want to know how to add method references to HashMap (replace "question").</p>
<p>p.s. I've come from C# where I simply write <code>Dictionary<Type, Action></code> :)</p>
| java | [1] |
5,533,047 | 5,533,048 | solution for selecting checkbox on datagridview | <p>i am using following code when inserting check box column to datagridview,</p>
<p><code>DataGridViewCheckBoxColumn checkBoxColumn = new DataGridViewCheckBoxColumn();
dataGridView1.Columns.Add(checkBoxColumn);
</code> </p>
<p>when i am trying to select checkbox, it is not selectecd (not checked or unchecked),
is there a better way to do this ?</p>
| c# | [0] |
2,198,183 | 2,198,184 | General C++ Performance Improvement Tips | <p>Could someone point me to an article, or write some tips right here about some c++ programming habits that are generally valid (no real drawbacks) and improves performance? I do not mean programming patterns and algorithm complexity - I need small things like how you define your functions, things to do/to avoid in loops, what to allocate on the stack, what on the heap, and so on.</p>
<p>It's not about making a particular software faster, also it's not about how to create a clean software design, but rather programming habits that - if you always apply them, you will make your code rather a little bit faster than a little bit slower.</p>
<p>Thanks :)</p>
| c++ | [6] |
4,743,247 | 4,743,248 | How to get the value member of a combobox in datagridview without editing the cell in vb? | <p>I have 4 columns in datagridview , 3 are textboxe and 1 is combobox columns respectively .
In my database , i am saving the the value member of the combobox column.After populating the datagridview , i am trying to edit one of the textbox column ,while executing query ,i saw that ,i am not getting the value member of the combobox column ,instead i am getting display member but if i select the item from the list then i am receiving the value member , it means
if i dont select from the list then it will take the display memeber.
Reply soon
Thanks </p>
| asp.net | [9] |
3,529,962 | 3,529,963 | variables in javascript | <p>I have two arrays sd[16][16] and gd[16][16] in javascript. I need to compare the values of the arrays.</p>
<pre><code>var score=0;
document.write("<table>");
for(c1=0; c1<16; c1++)
{ document.write("<tr>");
for(c2=0; c2<16; c2++)
document.write("<td onClick='changeColor(this);'>" + gd[c1][c2] + "</td>");
document.write("</tr>");
}
document.write("</table>");
function changeColor(tdd)
{
if(tdd.bgColor=='white')
{
tdd.bgColor='red';
if (gd[c1][c2] == sd[c1][c2])
score+=5;
else
score-=2;
}
else
{
tdd.bgColor='white';
}
}
</code></pre>
<p>However, when I try to display the score later, the score is not displayed.</p>
<pre><code>function scc()
{
document.getElementById('scf').innerHTML = score;
}
</script>
<br><br><center><button type='button' onclick='scc()'> Click to see current score</button> <p id="scf">0</p> </center>
<br><br> <center><input type="submit" value="Get Solution"/></center>
</code></pre>
<p>Could someone please tell me what I am doing wrong?</p>
| javascript | [3] |
5,455,223 | 5,455,224 | Python code to create a password encrypted zip file? | <p>What is the Python code to create a password encrypted zip file? I'm fine with using some apt-get'able utilities using system on the command line.</p>
| python | [7] |
1,052,716 | 1,052,717 | Populating Inner HTML In Each Statement | <p>I on success of an ajax call I am trying to populate each items real_price. What its doing is populating all the real_price tags of every item to the last value the service picks up.</p>
<p>How can I rewrite it to populate 1 at a time so every item has their specific price?</p>
<pre><code><div class="item">
<p class="price">$388.00</p>
<p class="part_number">VM2327T23A00T</p>
<p class="real_price"></p>
</div>
<div class="item">
<p class="price">$88.00</p>
<p class="part_number">AA327T23A00T</p>
<p class="real_price"></p>
</div>
<div class="item">
<p class="price">$38.00</p>
<p class="part_number">AA327T23A00T</p>
<p class="real_price"></p>
</div>
<script>
jQuery('.part_number').each(function () {
jQuery.ajax(
{
type: "POST",
url: "RealTimePricing.aspx/GetRealPrice",
data: "{pmber:' " + SearchSpring.jQuery(this).text() + "', lrice: ' " + jQuery(this).siblings('.price').text() + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
async: true,
cache: false,
success: function (msg) {
//NEED TO CHANGE SOMETHING HERE
jQuery('.real_price').html(msg.d);
</script>
</code></pre>
| jquery | [5] |
5,303,311 | 5,303,312 | Javascript classes and variable references | <p>I'm trying to solve this puzzle minded Javascript OOP problem.</p>
<p>So I have the following class :</p>
<pre><code>var ClassA = function() {
this.initialize();
}
ClassA.prototype = {
methods : ['alpha','beta','gama'],
initialize : function() {
for ( var i in this.methods ) {
this[this.methods[i]] = function() {
console.log(this.methods[i]);
}
}
}
}
var a = new ClassA();
</code></pre>
<p>When I call every method I expect to print the name of it, right? But here is what i get :</p>
<pre><code>a.alpha(); // returns gama ?!?
a.beta(); // returns gama ?!?
a.gama(); // returns gama
</code></pre>
<p>But when my class looks like this :</p>
<pre><code>var ClassB = function() {
this.initialize();
}
ClassB.prototype = {
methods : ['alpha', 'beta', 'gama'],
initialize: function() {
for ( var i in this.methods ) {
this.addMethod(this.methods[i]);
}
},
addMethod: function(method) {
this[method] = function() {
console.log(method);
}
}
}
var b = new ClassB();
b.alpha(); // returns alpha
b.beta(); // returns beta
b.gama(); // returns gama
</code></pre>
<p>Why is this happening ?</p>
| javascript | [3] |
5,975,049 | 5,975,050 | The latest technology in ASP.NET | <p>I am an ASP.NET developer. What is the latest technology in ASP.NET and also the documentation about it?</p>
| asp.net | [9] |
1,124,790 | 1,124,791 | PHP if with fetch from Mysql DB | <p>I can't get my head around why this wont work..</p>
<pre><code><?
(connect info and select DB etc here)
$term = $_POST['term'];
$sql = mysql_query("select * from evansu where username like '%$term%'");
if ($row==$term)
{
while ($row = mysql_fetch_array($sql))
echo 'ID: '.$row['ID'];
echo '<br/> First Name: '.$row['username'];
echo '<br/> Last Name: '.$row['name'];
echo '<br/> Phone: '.$row['Phone'];
echo '<br/><br/>';
}
else
echo "Nothing found, have a nice day!";
</code></pre>
<p>?></p>
<p>It says nothing found even if the value is in the DB, and if I remove the if code it works and shows the info. Help?</p>
| php | [2] |
2,001,910 | 2,001,911 | Why do we need LayoutTemplate in ListView control in ASP.NET? | <p>I am new to use ListView control in an ASP.Net application .</p>
<p>I am binding to a collection of data which has some data.</p>
<p>I saw many template in the listview control and there is LayoutTemplate as well.</p>
<p>If I don't use this , everything works fine but when I try to use LayOutTemplate i get error of some item place holder.</p>
<p>Can anyone please explain with example LayOutTemplate in layman's language ? </p>
| asp.net | [9] |
5,320,232 | 5,320,233 | Code check - Function to verify integers with optional return value | <p>I'm hoping someone could give me some input on how to improve this function. Its purpose is to evaluate whether a form input is a valid integer, and if not, either return a zero by default, or -1 if the second argument = true.</p>
<p>EDIT: Here is an updated version of the function I'm using. It seems the two most challenging parts are to ensure that an empty string doesn't evaluate as 0 when expecting -1 for empty strings ($neg=true), and evaluating inputs with left padded zeros as integers and not octals.</p>
<pre><code>function clean_integer($value, $neg=false)
{
if (!is_numeric($value)) {
if (!$neg) {
return 0;
else {
return -1;
}
}
$value = ltrim(trim($value), '0');
if (!$neg)
{
if ($value !== true && ((string)(int) $value) === ((string) $value)) {
return (int) $value;
}
else {
return 0;
}
}
else
{
if (!is_numeric($value)) {
return 0;
}
if ($value !== true && ((string)(int) $value) === ((string) $value)) {
return (int) $value;
}
else {
return -1;
}
}
}
</code></pre>
<p>I've been staring at this for too long and am convinced I'm making it terribly overcomplicated. </p>
| php | [2] |
3,744,025 | 3,744,026 | c++ initialization of an array of string pointers | <p>I want to initialize an array of <code>std::string</code> pointers of size that i get from a constructor. Also, i want to do the same for two <code>int</code> arrays but the code below doesn't compile:</p>
<pre><code>class MyQuickInitArray
{
public:
MyQuickInitArray(int size)
{
if(size <= 0)
{
throw new std::exception;
}
_size = size;
_counter = 0;
A = new std::string[size];
B = new int[size];
C = new int[size];
}
std::string& operator[](int j) {
if(j > _size)
{
throw std::out_of_range("out of range");
}
if(((B[j]<0) || (B[j]>=_counter)) || (C[B[j]]!=j))
{
// A[j] points to junk
_counter++;
A[j] = new std::string;
B[j] = _counter-1;
C[_counter-1] = j;
return A[j];
}
// the cell was instantiated before
return A[j];
}
~MyQuickInitArray(){};
private:
std::string* A[];
int B[];
int C[];
int _size;
int _counter;
};
</code></pre>
<p>How can i properly declare an array of size that i get from a ctor?</p>
<p><strong>EDIT:</strong></p>
<p>The error that occurs is:</p>
<pre><code>incompatible types in assignment of ‘std::string* {aka std::basic_string<char>*}’ to ‘std::string* [0]
</code></pre>
<p>And for the <code>int</code> arrays:</p>
<pre><code>incompatible types in assignment of ‘int*’ to ‘int [0]’
</code></pre>
| c++ | [6] |
4,849,839 | 4,849,840 | How to develop for original "iPhone" with latest SDK? | <p>I've seen similar questions to this but not too many definitive answers...</p>
<p>I used to have a version of Xcode (not sure where I got it) that would only target iPhone OS 3.1.3 devices and since I like to work with the least common denominator, this was cool with me. Recently I upgraded to the latest SDK so I can test my code on OS 4 as well. Now the lowest iPhone OS target I have is 3.2 but I have the original iPhone and according to iTunes 3.1.3 is the latest version for that device.</p>
<p>So right now I can't upgrade my phone to 3.2 and I can't set my target in Xcode to 3.1.3. What do I do? Should I reinstall the old SDK but at a different path? </p>
<p>It seems like Apple is trying to phase out the original iPhone altogether but that seems absurd to prevent developers from targeting a device that clearly still has it's place in the market.</p>
<p>Thanks</p>
| iphone | [8] |
3,479,320 | 3,479,321 | Calling a structure method inside a non-default structure constructor | <p>I have this very simple example that I am using to learn structs in C#:</p>
<pre><code>struct ScreenPosition
{
// These are the two private members of the structure
private int x;
private int y;
private int RangeCheckedX(int xPos)
{
if (xPos < 0 || xPos > 1280)
{
throw new ArgumentOutOfRangeException("X");
}
return xPos;
}
private int RangeCheckedY(int yPos)
{
if (yPos < 0 || yPos > 1024)
{
throw new ArgumentOutOfRangeException("Y");
}
return yPos;
}
// Declaring the non-default constructor
public ScreenPosition(int X, int Y)
{
this.x = RangeCheckedX(X); // ERROR HERE
this.y = RangeCheckedY(Y); // ERROR HERE
}
// Declaring the property X - Follows a syntax. See the C# quick reference sheet
public int X
{
get
{
return this.x;
}
set
{
this.x = RangeCheckedX(value);
}
}
// Declaring the property X - Follows a syntax. See the C# quick reference sheet
public int Y
{
get
{
return this.y;
}
set
{
this.y = RangeCheckedY(value);
}
}
}
</code></pre>
<p>I am getting this error at the "ERROR HERE" comment lines:</p>
<blockquote>
<p>The 'this' object cannot be used before all of its fields are assigned to</p>
</blockquote>
<p>Is it illegal to call a structure method in the non-default constructor to assign values to the structure members? </p>
| c# | [0] |
1,287,624 | 1,287,625 | iPhone etc: how to tell if the device has a camera? | <p>Version 3.1.3 if its relevant.</p>
<p>There is this suggestion which may work now, but in the future?</p>
<pre><code>NSString *device = [UIDevice currentDevice].model;
if([device isEqualToString:@"iPhone"])
</code></pre>
| iphone | [8] |
6,005,199 | 6,005,200 | Convert given time to GMT in java | <p>i had tried to convert the given date Mon Jul 04 00:00:00 IST 2011 in to GMT as like this 2011-07-04 18:10:47 GMT+00:00 2011 but it displays 3/7/11 6:30 PM This is my code</p>
<pre><code>java.text.SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
java.text.SimpleDateFormat res_format = new SimpleDateFormat("dd/mm/yyyy HH:mm");
java.util.Date date1 = format.parse("2011-07-04 00:00:00");
DateFormat gmtFormat = new SimpleDateFormat();
TimeZone gmtTime = TimeZone.getTimeZone("GMT+00");
gmtFormat.setTimeZone(gmtTime);
System.out.println("Current Time: "+date1);
System.out.println("Time:"+gmtFormat.format(date1));
</code></pre>
| java | [1] |
4,372,830 | 4,372,831 | Insert text before and after the selected text in javascript | <p>I want to put some specified text (where possible/any editable field) before and after any selected text in an HTML document.
<code>document.getSelection()</code> or <code>document.selection.createRange().text</code> returns only the text itself not the position.
Is there anyway to replace the selected text? Anyway to insert specific text before and after selcted text anywhere in the document?</p>
| javascript | [3] |
5,029,919 | 5,029,920 | Why is my Php Script Not Wroking Now? | <p>I want to get ip Details. On StalkOverflow, i came up with this
<a href="http://stackoverflow.com/questions/855967/how-do-i-retrieve-the-visitors-isp-through-php">http://stackoverflow.com/questions/855967/how-do-i-retrieve-the-visitors-isp-through-php</a></p>
<p>But this Php Code is no longer working on my server.</p>
<pre><code><?php
$ip=$_SERVER['REMOTE_ADDR'];
$url=file_get_contents("http://whatismyipaddress.com/ip/$ip");
preg_match_all('/<th>(.*?)<\/th><td>(.*?)<\/td>/s',$url,$output,PREG_SET_ORDER);
$isp=$output[1][2];
$city=$output[9][2];
$state=$output[8][2];
$zipcode=$output[12][2];
$country=$output[7][2];
?>
<body>
<table align="center">
<tr><td>ISP :</td><td><?php echo $isp;?></td></tr>
<tr><td>City :</td><td><?php echo $city;?></td></tr>
<tr><td>State :</td><td><?php echo $state;?></td></tr>
<tr><td>Zipcode :</td><td><?php echo $zipcode;?></td></tr>
<tr><td>Country :</td><td><?php echo $country;?></td></tr>
</table>
</body>
</code></pre>
<p>Why is it not working now? Please post full working code.</p>
| php | [2] |
1,473,326 | 1,473,327 | javascript Image Editing | <p>I want a simple image editor functionality for my site. My requirement is like that an image is being displayed and user can draw squares and shapes on image and save the co-ordinates so that when the image is reloaded the area are highlighted. So we have to provide a simple toolbox to user so that he can do the image editing on runtime.</p>
<p>There are few scripts available for the purpose but none seems to be close to my requirement. Can you people recommend a good script for that that is cross browser too?</p>
<p>Thanks in advance for the help.</p>
| javascript | [3] |
4,710,978 | 4,710,979 | PHP alternative to trac? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/349241/is-there-an-equivalent-to-trac-written-in-php">Is there an equivalent to Trac written in PHP?</a> </p>
</blockquote>
<p>Are there any PHP alternatives to Edgewall's Trac solution which works on Python, and not really portable?</p>
| php | [2] |
3,019,559 | 3,019,560 | ASP.NET "Could not Load Type" just on Server | <p>I have a ASP.Net 3.5 host. I just opened a new, C# Web project in visual studio 2010. I changed customerror to None and delete authentication mode line and select None in server control panel. Project works on local machine and says Hello World when I build and deploy in to server via FTP, I get an error it says Could not Load Type '_Default'
<%@ page language="C#" autoeventwireup="true" CodeFile="Default.aspx.cs" inherits="WebApplication._Default" %></p>
<p>my namespace is WebApplication and in class name is _Default Default.aspx.cs, </p>
<p>It works when I start in ISS, but It cannot start on server.</p>
| asp.net | [9] |
3,903,620 | 3,903,621 | View state vs Hidden field in asp.net | <p>How can we take decision for viewstate and hidden field in ASP.NET.</p>
<p>In my case i am using page cross post back and by using public properties of first page i am accessing them in second aspx page. </p>
<p>After getting public variable in second aspx page i need to access those value in second page but as soon as i do postback in second page, i am not able to find those value.</p>
<p>Hence to solve this issue i have two solution either use viewstate in second page or using hidden field in second page.</p>
<p>I am not able to decide which one should i use?</p>
| asp.net | [9] |
1,927,577 | 1,927,578 | what is the significance of asp.net webpart controls in today applications? | <p>what is the significance of asp.net webpart controls in today applications?</p>
<p>Where in we have AJAX,JQuery, MVC Controls are being used in today application.Does Webpart Controls still being used? Need to now know more detail in this regard.</p>
| asp.net | [9] |
3,663,308 | 3,663,309 | file processing in C++ | <p>I'm wondering if anybody can help me solving the following problem in C++:</p>
<p>I have a file where some time there is missing data i.e there are two consecutive TABs, then I need to transform the second TAB into "-999999" or "0" for example.
here is how the file looks like</p>
<pre><code> i_1 i_2 i_3 i_4 i_5
j_1 12 14 16
j_2 11 17 25
j_3 44 51 65
</code></pre>
<p>I want to compute the mean of the elements on the first row i.e( 12,14 and 16) as:</p>
<pre><code>sum+=tab[i][j];
mean = sum/5; (considering empty spaces =0)
</code></pre>
<p>thank you</p>
| c++ | [6] |
3,434,496 | 3,434,497 | Getting Android Play/Market ID of the user | <p>Is it possible to somehow get the ID of the user with which they are currently logged in on Andoid Play?</p>
<p>It would be really useful for the developers. They won't need to have users signed up on each application. They could just identify the user by their Android Play ID.</p>
| android | [4] |
2,493,154 | 2,493,155 | How to have html in Text attribute of asp Button | <p>I'm trying to include an <code><i></code> for the Text attribute for an asp button but it's just rendering the html as text...</p>
<pre><code><asp:Button runat="server" ID="modify" ToolTip="Modify" CssClass="btn btn-mini" OnClick="modify_Onclick" Text='<i class="icon-edit"></i>' />
</code></pre>
<p>I've got to be over thinking this...</p>
<p><strong>EDIT:</strong>
I'm using the twitter bootstrap framework. That's why the <code><i></code> tag
Here's an example: <a href="http://twitter.github.com/bootstrap/base-css.html#icons" rel="nofollow">http://twitter.github.com/bootstrap/base-css.html#icons</a></p>
| asp.net | [9] |
1,472,526 | 1,472,527 | how to set to call a function from the current object using settimer | <pre><code>function Something() {
this.var1 = 0;
this.var2 = 2;
this.mytimer;
this.getCars=function() {
//some code
};
this.start = function(l) {
this.updateTimer=setInterval("this.getCars();" , 5000);
};
}
var smth = new Something();
smth.start();
</code></pre>
<p>When I type in this.getCars() it does not work. if the function is global declared and i put in for example just getCars it works.
I don't know how to work out this problem because setInterval becomes as parameter a String.</p>
<p>Can somebody help me put with this?</p>
| javascript | [3] |
1,040,871 | 1,040,872 | Python widget/cursor detection? | <p>Beginner python learner here. I have a question that I have tried to Google but I just can't come up with the proper way to ask in just a few words (partly because I don't know the right terminology.)</p>
<p>How do I get python to detect other widgets? For example, if I wanted a script to check and see when I click my mouse if that click put focus on an entry widget on a (for example) website. I've been trying to get it to work in Tkinter and I can't figure out even where to begin.</p>
<p>I've seen this:</p>
<pre><code> focus_displayof(self)
Return the widget which has currently the focus on the
display where this widget is located.
</code></pre>
<p>But the return value for that function seems to be some ambiguous long number I can't decipher, plus it only works in its own application.</p>
<p>Any direction would be much appreciated. :)</p>
| python | [7] |
457,823 | 457,824 | Problem with Android Multicast Sockets | <p>I'm running some code on the nexus one - and I am having a very strange issue. The "server" sends UDP packets out on the multicast socket that the phone is joined to. The phone receives and sends stuff to the multicast group fine, but it appears that the phone chokes when it receives a large number of packets at one time.</p>
<p>For example, the server will occasionally send out 80 or so 512 byte packets in one go around. The phone starts receiving the packets, but then at the 31st packet (~16KB of data) the receive hangs (indicating that there is nothing on the socket anymore.) I've done wireshark testing and stuff so I know for sure that the packets are not being lost. Even if some are being lost, it is very strange that EVERY test produces the same result --- a large amount of data gets jammed onto the socket at one time, but the socket only allows me to socket.receive() for 16KB worth of data.</p>
<p>I have tried socket.setReceiveBufferSize() with a variety of values (up to 1MB) -- but that doesn't seem to work. Interestingly, a call to getReceiveBufferSize() tells me that the socket should hold roughly 100KB worth of data.</p>
<p>If I tell the server to slow down its send method (which I cannot deploy, I can only do that for testing purposes) - everything works fine, presumably because the packets aren't jammed onto the phone's socket all at one time (ie. I tell the server to wait 1/2 a second between packets.)</p>
<p>Has anyone else experienced this - if so - how did you get around it? I <em>cannot</em> switch the application to TCP.</p>
<p>Thanks!</p>
<p>Dan</p>
<p>PS. The Java code works fine if I run it on a regular machine...</p>
| android | [4] |
5,442,435 | 5,442,436 | Trouble fixing binascii odd length string issue | <p>I have a small script here that I need some help with:</p>
<pre><code>for song in songs:
slash = song.rindex('\\')
songbyte = slash + 2
if len(str(songbyte)) < 2:
#if songbyte < 10:
songbyte = "0" + str(songbyte)
f.write(binascii.a2b_hex(songbyte))
else:
f.write(binascii.a2b_hex("{0:x}".format(songbyte)))
f.close()
return
</code></pre>
<p>First off, I'm attempting to write a playlist. For testing purposes I'm writing one that contains 49 songs -- songs is a list that i'm iterating through containing 49 songs </p>
<p>I'm required to write songbyte -- It's a value that ranges from 8 to 72. At the moment I'm just iterating through and making sure it has the correct value for each songbyte (It's a copy of a known correct playlist, veryifying via diff and a hex editor).</p>
<p>My problem is that the line</p>
<pre><code>print(binascii.a2b_hex("{0:x}".format(songbyte)))
</code></pre>
<p>throws "TypeError: Odd-length string". Now, this is descriptive enough. Through investigating, I've determined that the value of songbyte when it's going to error is 8. What doesn't make sense, however, is that this error happens 37 songs into the list, and the majority of the the other songs' songbytes are also 8 -- and get caught with my len(str(songbyte)) < 2 check which adds a 0 -- but strangely this one doesn't.</p>
<p>Though I hope, I'm not really sure if this is enough information to help me solve the problem, short of providing complete details of the whole script though I don't think I could. Is there another way that I can write songbyte -- as hex -- to a file? </p>
| python | [7] |
5,541,477 | 5,541,478 | Is there a shorthand for document.write in JavaScript? | <p>in .NET you have <code><%=</code> or <code><%:</code> in PHP it's <code>echo</code>, but does JavaScript have a shorthand for <code>document.write()</code>?</p>
<p>Thanks</p>
<p>Mark</p>
| javascript | [3] |
4,075,611 | 4,075,612 | Launching application automatically in iphone 4 os | <p>I want to build an application that will be launched automatically on a particular date. Is there any way to do that in Iphone 4.0 OS. Actually I am building a sort of reminder that will send an sms for occasions like birthday, or other event. Thanks in advance for your help.</p>
| iphone | [8] |
3,549,972 | 3,549,973 | How to check how much money in the user account in a mobile network? | <p>I have my Android app and I want to know information about user network account.
So, how to check how much money in the user account in a mobile network from my android app?
Thank you for help and your time!</p>
| android | [4] |
5,662,644 | 5,662,645 | Convert C# Web App in C# library -- problem with Response Object | <p>I try to convert a part of a C# Web App to make a C# Library. </p>
<p>I used a Response object, but this one is no more recognized in the C# library. </p>
<p>Here some code: </p>
<pre><code>// Create a CAPTCHA image using the text stored.
CaptchaImage ci = new CaptchaImage(textCaptcha, 200, 50, "Century Schoolbook");
// Change the response headers to output a JPEG image.
this.Response.Clear();
this.Response.ContentType = "image/jpeg";
// Write the image to the response stream in JPEG format.
ci.Image.Save(this.Response.OutputStream, ImageFormat.Jpeg);
// Dispose of the CAPTCHA image object.
ci.Dispose();
</code></pre>
<p>How to use the Response object, or change it with something better?
Thx</p>
| c# | [0] |
2,401,050 | 2,401,051 | Changed const variable to static variables | <p>I adh some constants in my project.</p>
<pre><code>private const int refercePosition = 0.3;
</code></pre>
<p>I shifted the constants to the Settings file of my project (i.e into App.config) and using now in my project as.</p>
<pre><code>private static int refPos = Properties.Settings.Default.referencePosition;
</code></pre>
<p>Is this a good practice to decalre the variable as static instead of constant?<br/>
There are approximately 10 other constants in my project which which I did the same.</p>
<p>BTW, since App.config variables are runtime configurable but does declaring a variable as static defeat that purpose?</p>
| c# | [0] |
921,466 | 921,467 | Regarding sorting of list without iterating | <p>I have an array list , now i want to sort it without iterating..my array list conatain duplicate elements too , that duplicate elements should also be removed in final outcome sorted list , but all this should be done without iterating ...please advise</p>
<pre><code> ArrayList list=new ArrayList();
list.add("Ram");
list.add("Dinesh");
list.add("Sachin");
list.add("Dinesh");
</code></pre>
<p>Please advise</p>
| java | [1] |
125,005 | 125,006 | Opensource ASP.NET CMS or ECommerce that has sites which proposes beautifull templates? | <p>On PHP Platforms like Worldpress, Joomla, OSCommerce there are plenty of beautifull templates some even free, I cannot find any asp.net cms (the ones in Microsoft Gallery are boring) that has such a variety of templates, am I missing something in my search or do you know some ?</p>
| asp.net | [9] |
3,821,001 | 3,821,002 | auto update table in asp.net | <p>I have a problem. I was trying to make a table on a website. Everytime the user add a record it would display on the website. The user can add many more record on the table. My question is how do i make the table display the record automatically without saving the data into a database and retreiving it to dispaly on the the website table?</p>
| asp.net | [9] |
3,820,996 | 3,820,997 | Setting UI preference Summary field to the value of the preference | <p>New to Android, I have some code when the user changes a preference I update the Summary field in the UI preference to be the value they entered. However, when the preference activity is created I'd like to set the Summary fields to be the values in the corresponding preferences.
Please advise. Thanks. </p>
<pre><code>public class MyPreferenceActivity extends PreferenceActivity implements
OnSharedPreferenceChangeListener {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preference);
SharedPreferences sp = getPreferenceScreen().getSharedPreferences();
sp.registerOnSharedPreferenceChangeListener(this);
}
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
String key) {
Preference pref = findPreference(key);
if (pref instanceof EditTextPreference) {
EditTextPreference etp = (EditTextPreference) pref;
pref.setSummary(etp.getText());
}
}
}
</code></pre>
| android | [4] |
4,861,649 | 4,861,650 | javascript setTimeout problem | <p>Can any one tell me why i am loosing content in <a href="https://developer.mozilla.org/en/window.setTimeout" rel="nofollow">setTimeout</a> checked in firebug and i am loosing the content, though i the height of the content is showing!
all replies are welcome!</p>
<pre><code>function Tableslide_down(content,height)
{
var contentID = document.getElementById(content);
if(contentID.offsetHeight < height)
{
contentID.style.top = parseInt(slidingDiv.style.top) + 10 + "px";
setTimeout("Tableslide_down('"+content+"','"+height+"')",10);
}
contentID.style.display = "block";
}
</code></pre>
| javascript | [3] |
3,850,886 | 3,850,887 | Relative paths to getResourceAsStream method | <p>I have a jav aproject which is build through ant. It write the class files to output/classes/com/... path. One of my java classes needs input stream read from a file that is in a folder one level above output folder. Looks like if copy the file to the package folder under outptu/classes, it seems to work. But I do not want to palce my config file in output folder as it will be cleaned when I do ant clean. I want it to find it look above the output folder, in config folder and load it.</p>
<pre><code>public static final String CONFIG_FILE="/../../../../../../../Config.txt";
public static ConfigObj getConfigObj() throws IOException {
InputStream i=ConfigLoader.class.getResourceAsStream(CONFIG_FILE);
</code></pre>
<p>...</p>
<p>I want to know when I want to give raltivepath, what should it be relative to. I tried looking up , it says relative to classloader. What is classloader in this case? Is it output/classes/com....../config folder where my ConfigLoader.class lives?</p>
| java | [1] |
4,352,313 | 4,352,314 | How to make InfoButton Bordered | <p>How to make infobutton bordered? </p>
<pre><code>UIButton *button = [UIButton buttonWithType:UIButtonTypeInfoLight];
UIBarButtonItem *infoItem = [[UIBarButtonItem alloc] initWithCustomView:button];
[button addTarget:self action:@selector(infoPressed:) forControlEvents:UIControlEventTouchUpInside];
</code></pre>
<p>I have tried </p>
<pre><code>infoItem.style = UIBarButtonItemStyleBordered;
</code></pre>
<p>as well as </p>
<pre><code>button.style = UIBarButtonItemStyleBordered;
</code></pre>
<p>But none of them is working. Will appreciate help.</p>
| iphone | [8] |
5,277,553 | 5,277,554 | Difference between casting/conversion methods in C# | <p>there are many ways to cast/convert object to another by what the difference between those and if there is no difference why there are so many ways to achieve one thing? Isn't that damage to language?</p>
<p>let's say object obj to string.</p>
<pre><code>obj.ToString()
obj as string
(string)obj
Convert.ToString(obj)
</code></pre>
| c# | [0] |
4,850,642 | 4,850,643 | Need to avoid subprocess deadlock without communicate | <p>I need a execute a command that produces a lot of output and takes a lot of time to execute (> 30 minutes). I was thinking of using subprocess.Popen to do it. I need to capture the output of the command, so I pass PIPE to stdout and stderr.</p>
<p>A deadlock problem when using Popen.wait() is well documented on a lot of forums, so Popen.communicate() is the proposed way of avoiding the deadlock. The problem with that solution is that communicate() blocks until the command is completed. I need to print everything that arrives on stdout while the command is executed. If there is no output after 20 minutes, the script execution will be killed.</p>
<p>Here are some constraints that I need to respect:</p>
<ul>
<li>My Python version is 2.4.2 and I can't upgrade.</li>
<li>If the solution is still to use subprocess, I need to pass subprocess.PIPE to all std handles to avoid this bug: <a href="http://bugs.python.org/issue1124861" rel="nofollow">http://bugs.python.org/issue1124861</a></li>
</ul>
<p>Is there a way to do it?</p>
| python | [7] |
4,367,378 | 4,367,379 | Cannot Install JDK | <p>For the life of me, I can't install the JDK on Windows Vista. I keep getting the error, "This Software Has Already Been Installed on Your Computer. Would you like to reinstall it?" Problem is, it's evidently not on my computer, since I can't a) run Eclipse - I get "Could Not Find Java SE Runtime Environment" or b) Find any reference to Java from the command line when typing java -version - I get "Error opening registry key 'Registry/JavaSoft/Java Runtime Environment." Any ideas?</p>
| java | [1] |
160,125 | 160,126 | Why is PHP not replacing the variable in string? | <p>I dont get why this simple line of code does not work:</p>
<pre><code><?php
$someVariable = 0;
echo 'SomeVariable is $someVariable';
?>
</code></pre>
<p>It is printing out "SomeVariable is $someVariable" as opposed to the number 0. Is there something I am missing or some configuration option I have to enable?</p>
| php | [2] |
2,086,573 | 2,086,574 | What is the naming convention of JNI call in android | <p>For example, in android Java code, it calls a native method:</p>
<p>private native final String native_getParameters();</p>
<p>Where/how should I grep where is the C++ method defined 'native_getParameters();'?</p>
<p>Thank you.</p>
| android | [4] |
3,740,256 | 3,740,257 | C# 2.0 or 3.5 Design best practices for a dashboard application | <p>I am designing a dashboard application (An asp.net web app) where I get the latest updated data in a grid format. The grid should contain all the real time info. The dataaccess is from most of the tables and may have a 1-many relations and aggregates. So for each record, I loop thru 100's of tables to get the aggregates of all tables. What are the best practices for designing a dashboard application which is database read intensive. I am expecting more than 1000's to be able to access the app at a time. Any Design patterns I should follow? or any best practices etc.?</p>
| c# | [0] |
1,434,866 | 1,434,867 | How do you get real time updating in debug mode in NetBeans IDE | <p>What I want to do is have my program I am making in real time update to reflect the changes made in the code. I believe this is done in debugger mode but whenever I turn on the debugger and run the code and make a change I do not see it change in the program running. </p>
<p>Am I doing something wrong that it is not working?</p>
| java | [1] |
2,032,750 | 2,032,751 | creating new fragments with class and id behaves strangely in IE8 | <p>I have this piece of code which works in Firefox</p>
<pre><code>link = $('<a>link</a>');
var name = $("<h3 class='name section'>").append(link);
$('#container').append(name);
</code></pre>
<p>However this doesn't work in IE8. It seems that name doesn't get created at all. I tried adding <code>console.log('class of name'+name.attr('class'));</code> and inside the Developer Toolbar, the result is undefined.</p>
<p>Hence I look around for another option, and this works:</p>
<pre><code>var name = $('<h3>');
name.addClass('name');
name.addClass('section');
name = name.append(link);
</code></pre>
<p>It does exactly the same thing. I was wondering if IE8 has a thing against using HTML to define DOM fragments, so I tried this:</p>
<pre><code>var name = $("<div class='name section'>").append(link);
</code></pre>
<p>And this works in IE8.</p>
<p>What esoteric law of jQuery/IE8 did I break? Is it preferable to use addClass or setting the attribute of new DOM fragments over literal HTML?</p>
| jquery | [5] |
5,607,786 | 5,607,787 | Are there reserved kwargs for python's dict constructor? | <p>When using the kwarg-style dict initialization:</p>
<pre><code>In [3]: dict(a=1, b=2, c=3)
Out[3]: {'a': 1, 'b': 2, 'c': 3}
</code></pre>
<p>for some reason, defining the key 'from' raises a syntax error:</p>
<pre><code>In [4]: dict(to=0, from=1)
------------------------------------------------------------
File "<ipython console>", line 1
dict(to=0, from=1)
^
SyntaxError: invalid syntax
</code></pre>
<p>What is special about the key 'from'? Are there any other reserved keys for the kwarg-style initialization?</p>
<p>I am using Python 2.6.</p>
| python | [7] |
5,872,637 | 5,872,638 | How to find the object length using camera in android | <p>i want to find the object length using camera . I have search a lot and i have found
relation between distance & view angle.
Formula angle= arctan(d/2f)
but i m frustrated and not find any relative code. so please suggest me the working
code in order to find the object height using camera. if distance from the object is
know then how to find the object length
Thanks in advance </p>
| android | [4] |
32,585 | 32,586 | FileInputStream fis.read() gives exception | <p>I want to gain access to SD-CARD for this i am write some code :</p>
<pre><code>File f=Environment.getExternalStorageDirectory().getAbsolutePath();
// f=/mnt/sdcard
byte[] bytearray=new byte[4];
FileInputStream fis=new FileInputStream(f);
fis.read(bytearray,1,1); //This line gives exception
</code></pre>
<p>I can't figure out why this an exception</p>
| android | [4] |
1,522,754 | 1,522,755 | How to append to each element? | <pre><code>var form_error = jQuery('<div/>').attr('class', 'input-error').append(jQuery('<div/>').attr('class', 'error-label'));
var registration_fields_list = jQuery('<ul/>');
jQuery.each(registration_fields, function(){
var label = jQuery('<label/>').text(this.label);
var field = null;
field = jQuery('<input/>').attr({'name': this.input_name, 'class': this.input_class, 'type': (typeof this.type != 'undefined' ? this.type : 'text')});
console.log(jQuery('<li/>').append(label, field, form_error));
});
</code></pre>
<p>I cant find the problem, but the thing is that <code>form_error</code> appends only to the last <code>li</code>, not to each. Where i am wrong?</p>
| jquery | [5] |
4,185,099 | 4,185,100 | DataGridView for evry id show other datagrid view | <p>I am making little program and now made a data grid view which is showing from my database all <code>Project</code>. In database i have following tables <code>Project</code>, <code>Category</code>, <code>Job</code>. Now i want thath when user click in one line it will show new form with data grid view which will show Categoryes which are connected to Project. I know thath i should just drop from Data Sources but i cant because i have intermediate table. I already have SQL Query how i get the info from the target (Category).</p>
<pre><code>SELECT c.*
FROM Kategorija c
INNER JOIN Project_Category pc on pc.cId = c.cId
INNER JOIN Project p on pc.pId = p.pId
</code></pre>
<p>So pId should be input parameter.</p>
<p>Thanks for any suggestion and help!</p>
| c# | [0] |
3,720,833 | 3,720,834 | Using php and html, how can I count the number of times a selection is made from a drop down list? | <p>The program I'm working on is essentially a receipt maker for a restaurant. There is a drop down list which contains a bunch of foods taken from an array. The array includes the price for each item, and as of right now, the program will display any food item selected from the drop-down, list the individual prices, and add them up for a total. The problem I have is if someone selects the same item more than once, I have no way to register the quantity of said item. Basically, I need some code that checks the current selection against the past selections to see if their are any duplicates. I don't really know how to do that. <a href="https://gist.github.com/3881162" rel="nofollow">Here</a> is my code so far. Please take a look and pass on any advice. Thanks.</p>
| php | [2] |
8,340 | 8,341 | Placing image on bottom right corner of table cell does not work in Firefox and Safari | <p>I have the following table structure in my aspx page. I need to place the image at bottom right corner of a table cell. The code below works fine for IE and Chrome. But in Firefox and Safari, the image is displayed at the bottom right corner of the row, and not the cell.</p>
<pre><code> <table style="width:100%">
<tr>
<td valign="top" style="width:20%; position:relative">
<div>
//some controls here
</div>
<img src="~/images/Index.JPG" runat="server" style="position:absolute; right:0; bottom:0"/>
</td>
<td valign="top" style="width:80%">
<div>
//control here
</div>
</td>
</tr>
&nbsp;
<tr>
<td align="center" colspan="1" style="width: 20%">
//control here
</td>
<td align="center" colspan="2" style="width: 80%">
</td>
</tr>
<tr>
<td align="center" style="width:100%" colspan="2">
//control here
</td>
</tr>
</table>
</code></pre>
<p>Please help with this!!
Thanks.</p>
| asp.net | [9] |
2,968,252 | 2,968,253 | What is the difference between these two solutions - lambda or loop - Python | <p>I want to calculate the sum of even numbers within a domain. I have two solutions, but I'm not sure of the advantages/disadvantages of each. Which is the optimal solution?</p>
<pre><code>import sys
domain = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
Cal1 = sum(filter(lambda n : n % 2 == 0, domain))
Cal2 = sum([n for n in domain if n % 2 == 0])
sys.stdout.write("Cal1 = {0}\n".format(Cal1))
sys.stdout.write("Cal2 = {0}\n".format(Cal2))
</code></pre>
| python | [7] |
3,791,317 | 3,791,318 | Rebase array keys after unsetting elements | <p>I have an array:</p>
<pre><code>$array = array(1,2,3,4,5);
</code></pre>
<p>If I were to dump the contents of the array they would look like this:</p>
<pre><code>array(5) {
[0] => int(1)
[1] => int(2)
[2] => int(3)
[3] => int(4)
[4] => int(5)
}
</code></pre>
<p>When I loop through and unset certain keys, the index gets all jacked up. </p>
<pre><code>foreach($array as $i => $info)
{
if($info == 1 || $info == 2)
{
unset($array[$i]);
}
}
</code></pre>
<p>Subsequently, if I did another dump now it would look like: </p>
<pre><code>array(3) {
[2] => int(3)
[3] => int(4)
[4] => int(5)
}
</code></pre>
<p>Is there a proper way to reset the array so it's elements are Zero based again ?? </p>
<pre><code>array(3) {
[0] => int(3)
[1] => int(4)
[2] => int(5)
}
</code></pre>
| php | [2] |
2,193,278 | 2,193,279 | Alternative to nested `for` loops in Python | <p>I am trying to compare a list of forbidden folders read from a file. But we have to check if the task has the parent ID of the folder and then if that folder matches the forbidden folder. The lists I am looping through can contain many items.</p>
<pre><code>for task in tasks:
#Check the task is on their timesheet
if task["id"] == entry["item_id"]:
for folder in folders:
#See if the task is inside the folder
if task["parent_id"] == folder["id"]:
for forbiddenFolder in forbiddenFolders:
#If the folder is on the list
if forbiddenFolder == folder["name"]:
body_of_email +=( "Using a task within a folder that is not permiited " + forbiddenFolder + "\r\n" )
folder["name"]
break
</code></pre>
<p>This code uses three nested <code>for</code> loops, which might be slow. Can I make this more efficient?</p>
| python | [7] |
4,730,440 | 4,730,441 | adding callback to function - always | <p>I found myself using a weird way to add callback functions to my functions and I was wondering if there is a more generic way to add callbacks to functions, best case I would have a situation where all of my functions check the last given param for being a function and if so use it as a callback.</p>
<p>This is how I did it in the past:</p>
<pre><code>var myFunc = function( obj ) {
if ( arguments.length > 0 ) {
if ( _.util.typeofObj( arguments[arguments.length-1] ) === Function ) {
var callback = arguments[arguments.length-1];
}
}
// some code ...
if ( callback !== undefined ) {
callback();
}
};
var foo = myFunc( myObj, function(){
alert( 'Callback!' );
});
</code></pre>
<p>Any suggestions?</p>
| javascript | [3] |
2,792,090 | 2,792,091 | Developing N-Tier (layered) applications in Java | <p>I couldn't find a particular resource on developing layered applications with Java, so I'm askihg here. Please suggest some tutorials, books, or whatever that could teach me to develop layered applications in Java.</p>
| java | [1] |
450,085 | 450,086 | Browser Neutral Way to add options to a select element in javascript | <p>I just learned something interesting. The add method for the javascript select object in IE 6 takes only one parameter. It throws an error when you pass it two parameters which I believe is the <a href="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html.html">standard</a>, even as <a href="http://msdn.microsoft.com/en-us/library/aa768859(VS.85).aspx">documented</a> on the MSDN site.</p>
<p>My question is this. What is your best-practice recommendation for programmatically adding option elements to a select element in javascript?</p>
<ul>
<li>Call the add method differently based on the value of the user agent?</li>
<li>Wrap the select object in a class that provides the proper method signature?</li>
<li>Use a javascript library which does this for you (specify which library)?</li>
</ul>
| javascript | [3] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.