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 |
---|---|---|---|---|---|
1,197,724 | 1,197,725 |
Concatenate String
|
<p>I have the following javascript function:</p>
<pre><code><script type="text/javascript">
function quickCardRegister_OnCompleteSave() {
publishContent('This is a description',#{imagePath},'http://www.lala.com');
}
</script>
</code></pre>
<p>The imagePath variable is populated with value: <a href="http://localhost/img/30_w130px.gif" rel="nofollow">http://localhost/img/30_w130px.gif</a></p>
<p>I'm having the following script error: missing ) after argument list</p>
<p>publishContent('This is a description',http://localhost/img/30_w130px.gif,'http://www.lala.com');</p>
<p>How can i surround <a href="http://localhost/img/30_w130px.gif" rel="nofollow">http://localhost/img/30_w130px.gif</a> with quotes?</p>
<p>Thanks</p>
|
javascript
|
[3]
|
5,617,860 | 5,617,861 |
Rotating android view without affecting adjacent views
|
<p>I'm rotating a view containing an arrow in my app using the Matrix class. However, the arrow doesn't rotate around its center but moves a bit horizontally and vertically when rotating. I've experimented with margins and padding but without success.
Any hints much appreciated.</p>
|
android
|
[4]
|
3,081,190 | 3,081,191 |
How to get glow on the buttons like ipod/ipad in Android
|
<p>On Android application How can I get the glow effect on button when touched; I am looking for exact similar effect like ipod/iphone buttons </p>
|
android
|
[4]
|
3,348,920 | 3,348,921 |
NullReferenceException was unhandled - How to resolve it
|
<p>Here is my code:</p>
<pre><code>private void button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("Data Source=MANINOTEBOOK\\SQLEXPRESS;Integrated Security=SSPI;Initial Catalog=Casesheet");
con.Open();
SqlCommand cmd = new SqlCommand("select PatientID from FTR where PatientID='" + textBox1.Text + "'", con);
textBox2.Text = cmd.ExecuteScalar().ToString();
if (textBox2.Text == textBox1.Text)
{
Consultation cs = new Consultation(textBox1.Text);
cs.Show();
}
else
{
MessageBox.Show("Data not found");
}
}
</code></pre>
<p>When i compile this code i get an error "NullReferenceException was unhandled". I dont know how to resolve it. I need to check the value generated in the "execute scalar" command is null or not. Kindly help me in resolving this problem.</p>
|
c#
|
[0]
|
2,175,804 | 2,175,805 |
Trying to get a JSONObect to tokener help please ?
|
<p>I need to get some information from an JSONArray and i thought tokener would do it. Heres my code</p>
<pre><code>try{
JSONArray jArray = new JSONArray(result);
for(int i=0;i<jArray.length();i++){
String data = jArray.getString(i);
JSONObject json_data = (JSONObject)new JSONTokener (data).nextValue();
String query = json_data.getString("name");
JSONArray locations = json_data.getJSONArray("locations");
//Get an output to the screen
txt.setText(query);
}
</code></pre>
<p>The actual array is filling with data from my database via http post.</p>
<p>Field names are <code>id</code>, <code>name</code>, <code>servings</code>, <code>description</code>.</p>
|
android
|
[4]
|
3,447,562 | 3,447,563 |
context Switch Deadlock
|
<p>When I Run My Application After Some Second This Exception Occurred. what is exception and How I Can Handle This Exception </p>
<blockquote>
<p>The CLR has been unable to transition from COM context 0x647f10 to COM
context 0x648080 for 60 seconds. The thread that owns the destination
context/apartment is most likely either doing a non pumping wait or
processing a very long running operation without pumping Windows
messages. This situation generally has a negative performance impact
and may even lead to the application becoming non responsive or memory
usage accumulating continually over time. To avoid this problem, all
single threaded apartment (STA) threads should use pumping wait
primitives (such as CoWaitForMultipleHandles) and routinely pump
messages during long running operations.</p>
</blockquote>
|
c#
|
[0]
|
3,556,954 | 3,556,955 |
I am trying to create a program that takes a list of numbers from the user and checks whether or not the first number given in repeated in the list
|
<p>i know i can use the input function in conjunction with the eval function to input a list of numbers:</p>
<pre><code>numbers = eval(input("enter a list of numbers enclosed in brackets: "))
</code></pre>
<p>Also, given a list named items, i can get the list of all the elements of items, except the first one, with
the expression:</p>
<pre><code>items[1:]
</code></pre>
<p>im just not sure how to go about getting the program to do what i want it to do</p>
|
python
|
[7]
|
3,458,689 | 3,458,690 |
sort dictionary of objects
|
<p>I have a dictionary of objects where the key is a simple string, and the value is a data object with a few attributes. I'd like to sort my dictionary based on an attribute in the values of the dictionary. i have used this to sort based on the dictionaries values </p>
<pre><code>sorted = dict.values()
sorted.sort(key = operator.attrgetter('total'), reverse=True)
</code></pre>
<p>This yields a sorted list of values (which is expected) and I lose my original keys from the dictionary (naturally). I would like to sort both the keys and values together... how can I achieve this? Any help would be greatly appreciated?</p>
|
python
|
[7]
|
2,284,608 | 2,284,609 |
Remote function for validation
|
<p>I keep getting an undefined for the val that gets passed and not sure why when there's something being put for the form field.</p>
<pre><code>$('#addNewUserForm input[name="username"]').rules('add', {
remote: {
type: 'post',
url: 'addnewuser/is_username_available',
data: {
'username': function() { return $('#username').val(); }
},
dataType: 'json'
}
});
</code></pre>
|
jquery
|
[5]
|
3,700,416 | 3,700,417 |
Call php class method from string with parameter
|
<p>I am having trouble calling a <strong>class method</strong> from a string in PHP. Here's a simple example. Once I get this working I'll be using a variable as the method name.</p>
<p>Here's how I'd be calling the method normally:</p>
<pre><code>$tags_array = $this->get_tags_for_image($row["id"]);
</code></pre>
<p>Here's how I'm trying but getting an error:</p>
<pre><code>$tags_array = call_user_func('get_images_for_tag', $row["id"]);
</code></pre>
<p>I must be missing the scope but I can't figure out how to call the method.</p>
<p>----EDIT
Figured out that this calls the method but <strong>$row</strong> is undefined now I believe</p>
<pre><code>$tags_array = call_user_func(array($this, 'get_images_for_tag'), $row["id"]);
</code></pre>
<p>Full code block:</p>
<pre><code> $images = call_user_func(array($this, 'get_images_for_tag'), $filter);
foreach ($images as $row){
$tags_array = call_user_func(array($this, 'get_images_for_tag'), $row["id"]);
foreach ($tags_array as $tag_row){
$tags_array[] = $tag_row["tag"];
}
$image_array []= array (
'url' => $this->gallery_path_url . '/'. $row["name"],
'thumb_url' => $this->gallery_path_url . '/thumbs/' . 't_'. $row["name"],
'id' => $row["id"],
'description' => $row["description"],
//'url' => $row["url"],
'tags' => $tags_array
);
}
</code></pre>
|
php
|
[2]
|
5,731,457 | 5,731,458 |
Searching records from flatfile in C++
|
<p>I have written a snippet in C++ to search for record in a flatfile. The code does not work though. Below is the code i have written</p>
<pre><code>case 4:
{
cout<<"You Entered 4 (This Parses and searches BankAccount flatfile)"<<endl;
inputFile>>SearchParam;
cout<<"Enter Search criteria:"<<SearchParam;
fstream inputFile; //file stream object
inputFile.open("BankAccount.txt", ios::in);
struct Bank
{
string AccountName;
string AccountNumber;
string AccountBalance;
}
//Array of bank record entries
Bank Details[20];
//Do until AccountName = SearchParam (Search by AccountName)
i = 0;
do{
getline(BankAccount, Details[i].AccountName,' ');
getline(BankAccount, Details[i].AccountNumber,' ');
getline(BankAccount, Details[i].AccountBalance,' ');
i++;
}
while (!BankAccount.eof()&& SearchParam != AccountName)
}
break;
</code></pre>
|
c++
|
[6]
|
5,996,881 | 5,996,882 |
Getting a NullReferenceException
|
<p>I'm getting this: </p>
<pre><code> private object setReportValues(object report, FormCollection values)
{
PropertyInfo[] properties = report.GetType().GetProperties();
foreach (PropertyInfo property in properties)
{
string val = values.GetValue(property.Name).ToString();
property.SetValue(report, val, null);
}
return report;
}
</code></pre>
<p>Exception is on <code>string val = values.GetValue(property.Name).ToString();</code>. Do I have to check for nulls before?</p>
|
c#
|
[0]
|
1,781,238 | 1,781,239 |
Creating Google Location URL by using latitude & longtitude pairs
|
<p>I have a code where I'm retrieving latitude and longtitude information. I'm wondering what tools I need on hand in order to create a google maps URL.</p>
<p>I'm not interested to show that information on map but I would like to be able to create a link (Google Maps URL for latitude and longtitude info). Is that possible? If yes, I appreciate if you can direct me what tools I need in order to achieve that functionality.</p>
<p>Thanks in advance.</p>
|
android
|
[4]
|
5,754,665 | 5,754,666 |
Python: How to extract required information from a string?
|
<p>I am new to Python. Is there a StringTokenizer in Python? Can I do character by character scanning and copying.</p>
<p>I have the following input string</p>
<pre><code>data = '123:Palo Alto, CA -> 456:Seattle, WA 789'
</code></pre>
<p>I need to extract the two (city, state) fields from this string. Here is the code I wrote</p>
<pre><code>name_list = []
while i < len(data)):
if line[i] == ':':
name = ''
j = 0
i = i + 1
while line[i] != '-' and line[i].isnumeric() == False:
name[j] = line[i] # This line gives error
i = i + 1
j = j + 1
name_list.append(name)
i = i + 1
</code></pre>
<p>What should I do?</p>
|
python
|
[7]
|
4,758,792 | 4,758,793 |
Iterate through class members in order of their declaration
|
<p>I got this problem writing a little GUI lib that maps classes to simple table views. Every class member of a certain type = column, and order of columns is important. But...</p>
<pre><code>class Person(object):
name = None
date_of_birth = None
nationality = None
gender = None
address = None
comment = None
for member in Person.__dict__.iteritems():
if not member[1]:
print member[0]
</code></pre>
<p>output:</p>
<pre><code>comment
date_of_birth
name
address
gender
nationality
...
</code></pre>
<p>ugh, the oder got all mixed up...desired output:</p>
<pre><code>name
date_of_birth
nationality
gender
address
comment
</code></pre>
<p>Is there a way to do it without maintaining additional <code>OrderedDict()</code> of columns?</p>
|
python
|
[7]
|
778,645 | 778,646 |
What is the most efficient way to get the highest and the lowest values in a Array
|
<p>is there something like PHP: <code>max()</code> in javascript?</p>
<p>lets say i have an array like this:</p>
<pre><code>[2, 3, 23, 2, 2345, 4, 86, 8, 231, 75]
</code></pre>
<p>and i want to return the highest and the lowest value in this array. What is the fastest way to do that?</p>
<p>i have tried:</p>
<pre><code>function madmax (arr) {
var max = arr[0],
min = arr[1]
if (min > max) {
max = arr[1]
min = arr[0]
}
for (i=1;i<=arr.length;i++){
if( arr[i] > max ) {
max = arr[i]
}else if( arr[i] < min ) {
min = arr[i]
}
}
return max, min
}
madmax([123, 2, 345, 153, 5, 98, 456, 4323456, 1, 234, 19874, 238, 4])
</code></pre>
<p>Is there a simpler way retrieve the max and min value of a array? </p>
|
javascript
|
[3]
|
2,870,408 | 2,870,409 |
.hasClass() seem to always return true when used inside a .click() function, why?
|
<pre><code><ul id="list">
<li>item 1</li>
<li>item 2</li>
</ul>
$('#list li').click(function () {
alert($(this).hasClass('active')); // supposed to be an if
$(this).parent('ul').children('li').removeClass('active');
$(this).addClass('active');
});
</code></pre>
<p>Why does "$(this).hasClass('active')" always return true?</p>
|
jquery
|
[5]
|
2,302,592 | 2,302,593 |
the dreaded UTF-8 BOM
|
<p>I read your answer to reformat php files used by includes and it did remove the problem. My question is we are working on a web site that needs to display different laguages, will this be a problem?</p>
<p>Thanks Conrad</p>
|
php
|
[2]
|
1,330,117 | 1,330,118 |
passing the datagrid row value to the next form label
|
<p>hi i am working on winform and i have a datadrid view, i have a context menu strip. on that edit is written. when i click on datadrid, right click a context menu is open with edit. when clicked it should pass the value to a new form, i have written the code for transfer but it is not passing i dont know whats the problem here</p>
<pre><code> private void editToolStripMenuItem_Click(object sender, EventArgs e)
{
Form6 f = new Form6();
f.label1.Text = dataGridView1.SelectedRows[0].Cells[0].Value.ToString();
}
</code></pre>
<p>is the code correct?</p>
|
c#
|
[0]
|
4,998,131 | 4,998,132 |
Can I create an activity for a particular task without that task coming to the foreground?
|
<p>Here's my use case:<br>
The app starts at a login screen. You enter your credentials and hit the "Login" button. Then a progress dialog appears and you wait for some stuff to download. Once the stuff has downloaded, you are taken to a new activity. Exactly which activity you are taken to depends on the server response.</p>
<p>Here's my problem:<br>
If you go HOME during this login/download process, at some point in the near future your download will complete and will invoke <code>startActivity()</code>. <strong>So then the new activity will be pushed to the foreground, rudely interrupting the user.</strong> I can't start the activity before I start the download, because, as I mentioned earlier, the activity I start depends on the result of the download.</p>
<p>I would obviously not like to interrupt the user like this. One way to solve this is to refrain from calling <code>startActivity()</code> until the user returns to the app. I can do this by keeping track of the LoginActivity's <code>onStop()</code> and <code>onRestart()</code>. <strong>But I'm wondering, is there any way to create the activity while it is in the background?</strong> That way the user returns to the app and he is ready to go... otherwise he would have to wait for the new activity to be created (which could take some time because the <em>new</em> activity <em>also</em> has to download and display some data).</p>
<p><strong>Update:</strong>
Guess what? I LIED! I could have sworn that starting this activity was causing it to come to the foreground, but I went back to test it again and the problem has magically disappeared. I tested in both 1.6 and 2.0.1 and both OSes were smart enough not to bring a backgrounded task to the front.</p>
|
android
|
[4]
|
5,967,658 | 5,967,659 |
jquery/javascript object required error
|
<p>I am working in an ASP .net mvc project. The weird issue is I am running a javascript/jquery which randomly gives object required error. Sometimes it occurs but sometime it does not occur at all. What I am doing is making an explicit link click call to load a page as follows:</p>
<pre><code>function LoadPopup()
{
$("#page2link").click();
}
</code></pre>
<p>I call <code>Loadpopup()</code> in <code>$(document).ready()</code></p>
<p>After the above gets executed, page2 loads and the javascript for page2 is trying to run but I dont know why suddenly page2's javascript throws error. I don't know exactly at what line it throws error. The break point comes at <code>MicrosoftAjax.cs[Dynamicfile]</code>.</p>
<p>I am wondering why my debugger does not hit the breakpoint that I placed in page2's javascript. The stackj trace however shows a list of "java script anonymous functions" and also shows that these anonymous fucntions are called from <code>loadpopup()</code>.</p>
<p>Some more information. I am having a master page. <code>Loadpopup()</code> runs when mystartup.aspx loads, which inherits from the master page. Can anyone please help me in this regard? Please let me know if you need more detail?</p>
|
jquery
|
[5]
|
3,150,074 | 3,150,075 |
Backgound mode in iphone
|
<p>How to play ringtone and vibration with alert message in background mode in iPhone ?
Any help would be highly appreciated?</p>
|
iphone
|
[8]
|
114,180 | 114,181 |
How do I use sessions in PHP?
|
<p>i am building a php based website but now i need to give user a session, i.e the user can log in to website and have his session. after he should signout. how can i achieve this.?</p>
|
php
|
[2]
|
2,989,008 | 2,989,009 |
use std::logical_and to combine two conditions
|
<pre><code> int nums[] = {7, 6, 12, 9, 29, 1, 67, 3, 3, 8, 9, 77};
std::vector<int> vecInts(&nums[0], &nums[0] + sizeof(nums)/sizeof(nums[0]));
int countBoost = 0;
// (i > 5 && i <=10)
countBoost = std::count_if(vecInts.begin(), vecInts.end(),
boost::bind(std::logical_and<bool>(),
boost::bind(std::greater<int>(), _1, 5),
boost::bind(std::less_equal<int>(), _1, 10))
);
</code></pre>
<p>Now, I need to implement the same logical with pure STL. How can I do that?</p>
<p>I have tried the following code and it doesn't work:</p>
<pre><code>int countSTL = std::count_if(vecInts.begin(), vecInts.end(),
std::logical_and<bool>(std::bind2nd(std::greater<int>(), 5), std::bind2nd(std::less_equal<int>(), 10))
);
</code></pre>
<p>Thank you</p>
<p>// Updated //</p>
<pre><code>In Effective STL Item 43, Meyers indicates as follows:
vector<int>::iterator i = find_if(v.begin(), v.end(),
compose2(logical_and<bool>(), bind2nd(greater<int>(), x),
bind2nd(less<int>(), y)));
</code></pre>
<blockquote>
<p>But compose2 is NOT a standard function object adapter.</p>
</blockquote>
|
c++
|
[6]
|
1,251,425 | 1,251,426 |
Is there a python module to solve linear equations?
|
<p>I want to solve a linear equation with three or more variables .Do we have a library in python to do it? Please provide me with the documentation link.</p>
|
python
|
[7]
|
3,917,198 | 3,917,199 |
PHP Validation of _FILES
|
<p>I have a form through which users can upload an image. On my home machine I was validating like so:</p>
<pre><code>if(isset($_FILES['image']['name']))
</code></pre>
<p>And it was working fine, but it fails on my work machine. I need to use:</p>
<pre><code>$_FILES['image']['name'] != ''
</code></pre>
<p>I've tried empty($_FILES['image']), but this doesn't work either.
I was just wondering why this would be the case?</p>
|
php
|
[2]
|
1,028,638 | 1,028,639 |
Android alarm manager not working on Samsung Galaxy phone
|
<p>I have created an app which polls a server to fetch SMS that have to be sent to our users. For the polling functionality i have used the alarm manager to fire every 5 min to poll server</p>
<pre><code>AlarmManager alarm = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
Intent pintent = new Intent(this, SMSSender.class);
PendingIntent pIntent = PendingIntent.getBroadcast(this,0,pintent, 0);
if(checkbox.isChecked()) {
long interval = 60*Integer.valueOf(PreferenceManager.getDefaultSharedPreferences(this).getString("pref_poll_interval", "5000"));//5mins;//5mins
long firstPoll = SystemClock.elapsedRealtime() + 60*Integer.valueOf(PreferenceManager.getDefaultSharedPreferences(this).getString("pref_poll_interval", "5000"));
alarm.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, firstPoll, interval, pIntent);
Log.d("SMS_GATEWAY", "alarm manager turned on "+interval);
}else {
alarm.cancel(pIntent);
Log.d("SMS_GATEWAY", "alarm manager turned off");
}
</code></pre>
<p>I have tested the application on the emulator against the 2.2 build and everything works fine, now test the final out of SMS going out i have installed the app on a Samsung Galaxy S phone. </p>
<p>Once the app is installed and the preference to poll server is selected, nothing really happens.</p>
<p>What could be the problem</p>
|
android
|
[4]
|
1,716,834 | 1,716,835 |
Writing Yahoo! Bot: Why can't I fetch a web page on Yahoo! mail with help of PHP?
|
<p>I want to write a bot that fetches my mail on Yahoo! but my first problem is I can't fetch the web page where login and password have to be filled in. I do it so:</p>
<pre><code><?php
$the_url = "http://www.yahoo.com/r/l6";
$ua_s = "Opera/9.62 (Windows NT 5.1; U; En) Presto/2.1.1";
$c = curl_init($the_url);
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
curl_setopt($c, CURLOPT_USERAGENT, $ua_s);
$the_page = curl_exec($c);
curl_close($c);
echo $the_page;
?>
</code></pre>
<p>But when I do that I get a blank page.</p>
|
php
|
[2]
|
4,801,964 | 4,801,965 |
Package naming uniqueness for applications?
|
<p>When creating an android app, we need to supply a package name in the manifest.</p>
<pre><code><manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.me.foo">
</code></pre>
<p>I believe this uniquely identifies an application, such that we can't upload an app to marketplace if another app already exists with the same package name.</p>
<p>Is it possible to extend a package name though without collision? For example:</p>
<pre><code>package="com.me.foo"
package="com.me.foo.grok"
</code></pre>
<p>Will the second application be accepted by the marketplace, even though it's a substring of the first package name? </p>
<p>Thanks</p>
|
android
|
[4]
|
4,407,076 | 4,407,077 |
Parsing a url in json format in android application
|
<p>I am developing an android application in which i have to parse the url in json format.Url is </p>
<p><a href="http://search.yahooapis.com/NewsSearchService/V1/newsSearch?appid=YahooDemo&output=json" rel="nofollow">http://search.yahooapis.com/NewsSearchService/V1/newsSearch?appid=YahooDemo&output=json</a></p>
<p>I have tried by making json format object and then passing values.Has anyone implemented it before,If yes can he help me?</p>
<p>Thanks in advance
Tushar</p>
|
android
|
[4]
|
502,285 | 502,286 |
how to get back in navigation view using timer
|
<p>hi i am using this code for getting previous view </p>
<pre><code>NSTimer *theTimer = [NSTimer scheduledTimerWithTimeInterval:3.0
target:self
selector:@selector(pictureTimerFired:)
userInfo:nil
repeats:NO];
- (void) pictureTimerFired:(NSTimer*)theTimer {
NSLog(@"Timer fired, closing picture");
}
</code></pre>
<p>but what happened is it directly quit from application and displays icon how can i resolve this </p>
|
iphone
|
[8]
|
5,347,245 | 5,347,246 |
What would be a good free C++ e-book or tutorial series (preferably text)?
|
<blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list">The Definitive C++ Book Guide and List</a> </p>
</blockquote>
<p>I have already learned the <em>very</em> basics (<em>went through the entirety of <a href="http://www.learncpp.com" rel="nofollow">http://www.learncpp.com</a></em>) and I would like something to complement it; could you perhaps recommend me something which would help me continue on what I have already learned and/or to get me into building applications with a graphical user interface library?</p>
<p>Something that would involve examples which could be useful in real life would be great, too, but not necessary.</p>
|
c++
|
[6]
|
2,504,321 | 2,504,322 |
TypeError when retrieving random digits
|
<p>I am trying to generate a random three digit extension:</p>
<pre><code>>>> ''.join(str(x) for x in random.sample(range(1,10),3))
</code></pre>
<p>It works in the prompt. However, when I run the program, it raises a <code>TypeError: str object is not callable</code>. This is the line that I have:</p>
<pre><code> filename = hashlib.md5(imagefile.getvalue()).hexdigest() +
''.join(str(x) for x in random.sample(range(1,10),3)) + '_thumb' + '.jpg'
</code></pre>
<p>What am I doing wrong here and how would I fix it?</p>
<p>Thank you for the help. I had invoked str previously in the code, which was causing the error:</p>
<pre><code>str=""
for c in i.chunks():
str += c
...
</code></pre>
|
python
|
[7]
|
3,134,472 | 3,134,473 |
Need comprehensive list of all native objects
|
<p>I'm getting exactly what I want when I do this <code>console.dir(this)</code> in Chrome.<br />
Is there a way to get that into an array some how?<br /><br />
So I've tried to do something like this to get started:</p>
<pre><code>for(var o in console.dir(this)) {
console.log(o);
}
</code></pre>
<p>All I get is "undefined" and it prints the list into the console again.<br /><br />
I really just need a name list of all Native Javascript Objects and their respective methods and attributes without the hassle of manually creating and maintaining a monstrous list. Ideally the solution would be a dynamically created array of everything; either flat or multidimensional array so I can iterate through it.</p>
|
javascript
|
[3]
|
2,856,453 | 2,856,454 |
PHP login authentication problem (beginner)
|
<p>scenario is I have different access levels on this site, I have the simple login process working for all valid users however I am now trying to seperate the different users fo different access to pages.</p>
<p>here is my code at the start of my page:</p>
<pre><code>// CHECKS IF THE USER HAS LOGGED IN
session_start();
if(!isset($_SESSION['logged_in']) || !$_SESSION['logged_in']){
header("location:index.php");
}
if(!$_SESSION['mystatus']=='1'){
header("location:access_error.php");
}
</code></pre>
<p>so basically I want this page to only be accessible by users with the access level of 1 if they are logged in however do not have the correct access level direct them accordingly.</p>
<p>at the moment it allows users who have logged in with different access levels (e.g 3) to still view this page.</p>
<p>help please. </p>
<p>many thanks,</p>
|
php
|
[2]
|
4,889,493 | 4,889,494 |
Jquery: why my 'find()' method not updating?
|
<p>i have a function to find the length of finding class, but it not working always return the length is '0';</p>
<p>some thing is wrong with my code: can any one advice me the proper way. but i need to use the same structure of the code style to achieve this.</p>
<p>look on to my code :</p>
<pre><code><div id='list'>
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
</ul>
<p></p>
</div>
function callMe(params){
$(params.list).click(function(){
$(this).addClass('c_on');
var length = $(params.list).find('.c_on').length;
$('p').text(length)// return always 0, even i clicked no.of list.
})
}
$(document).ready(function(){
var obj = {
list : $('ul').find('li')
}
callMe(obj);
})
style :
li.c_on{
border:1px solid green;
}
</code></pre>
<p>
Here is the fiddle : <a href="http://jsfiddle.net/AeGvf/1/" rel="nofollow">http://jsfiddle.net/AeGvf/1/</a></p>
|
jquery
|
[5]
|
4,250,623 | 4,250,624 |
(function(){})() Is there any documentation of this?
|
<blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/1140089/how-does-an-anonymous-function-in-javascript-work">How does an anonymous function in JavaScript work?</a><br>
<a href="http://stackoverflow.com/questions/6771406/what-does-this-javascript-snippet-mean">What does this JavaScript snippet mean?</a> </p>
</blockquote>
<p>I use in my scripts: </p>
<pre><code>(function(){
...[code]..
})()
</code></pre>
<p>I can't find documentation about this, i have see scripts when this form take args. </p>
<pre><code>(function(){
...[code]..
})(arg1,arg2)
</code></pre>
<p>Somebody have a link or a good explanation about this javascript function? </p>
|
javascript
|
[3]
|
5,001,501 | 5,001,502 |
How to remove folder path within zip file.I want only txt files in zip file
|
<p>I am created the zip file in this path "D:\Nagaraj\Dotnet\Zipfile\Zipfile\Filebuild\Hi.zip". But within this Hi.zip file creating the folders "D:\Nagaraj\Dotnet\Zipfile\Zipfile\Filebuild\Hi" after that added 2 txt files showing....So I need to remove folder path in zip file ...I am using following code and sharpziplib library...thanks in advance.</p>
<pre><code>*enter code here*
StartZip("D:/Nagaraj/Dotnet/Zipfile/Zipfile/Filebuild/Hi/", Server.MapPath("Filebuild/Hi.zip"));
public void StartZip(string directory, string zipFileName)
{
ZipFile z = ZipFile.Create(zipFileName);
z.BeginUpdate();
string[] filenames = Directory.GetFiles(directory);
foreach (string filename in filenames)
{
z.Add(filename);
string s = Path.GetFileName(filename);
}
z.CommitUpdate();
z.Close();
}
</code></pre>
|
asp.net
|
[9]
|
99,481 | 99,482 |
'java.lang.UnsatisfiedLinkError' in a native method on renaming package
|
<p>My application using some native methods and I want to rename my project package to a more useful package name, but when I rename the package, it gives '<strong>java.lang.UnsatisfiedLinkError</strong>' in class having native methods. </p>
<p>I'll be glad if anybody could tell me the right procedure I should follow to rename my project package without having any conflict with native code of the project.</p>
|
android
|
[4]
|
604,576 | 604,577 |
Or statement in PHP
|
<p>I want to add an ID to a span element if the page is either 'a' or 'b'.</p>
<p>My code so far is this:</p>
<pre><code><span class="subnav2" <? if(($page == 'a') || ($page == 'b')): ?> id="active"<? endif ?>>
</code></pre>
<p>but it only adds the class to the span when 'a' is true. What am I doing wrong?</p>
<p>The value of $page is:</p>
<pre><code><?
$path = basename($_SERVER['PHP_SELF']);
$page = basename($path);
$page = basename($path, '.php');
$page = str_replace('_',' ',$page);
$page = str_replace('.php','',$page);
$page = ucfirst($page);
?>
</code></pre>
|
php
|
[2]
|
2,017,626 | 2,017,627 |
How to change class implementation efficiently
|
<p>I'd like to change the implementation depending on a constructor argument. Below is an example showing what I mean:</p>
<pre><code>class Device(object):
def __init__(self, simulate):
self.simulate = simulate
def foo(self):
if simulate:
self._simulate_foo()
else:
self._do_foo()
def _do_foo(self):
# do foo
def _simulate_foo(self):
# simulate foo
</code></pre>
<p>Now every call to <code>foo()</code> invokes an <code>if</code> clause. To avoid that I could bind the correct method dynamically to <code>foo</code>.</p>
<pre><code>class Device(object):
def __init__(self, simulate):
if simulate:
self.foo = self._simulate_foo
else:
self.foo = self._do_foo()
def _do_foo(self):
# do foo
def _simulate_foo(self):
# simulate foo
</code></pre>
<p>Are there any drawbacks why this should not be done or other drawbacks I'm not aware? Is this really faster?(I'm aware that inheritance is another option)</p>
|
python
|
[7]
|
2,904,343 | 2,904,344 |
Android Web Application Submission process
|
<p>Any please post me the process of submission of Web app to Android market</p>
|
android
|
[4]
|
3,414,768 | 3,414,769 |
equals method overrides equals in superclass and may not be symmetric
|
<p>I have below Findbugs error for my "equal" method,</p>
<blockquote>
<p>This class defines an equals method
that overrides an equals method in a
superclass. Both equals methods
methods use instanceof in the
determination of whether two objects
are equal. This is fraught with peril,
since it is important that the equals
method is symmetrical (in other words,
a.equals(b) == b.equals(a)). If B is a
subtype of A, and A's equals method
checks that the argument is an
instanceof A, and B's equals method
checks that the argument is an
instanceof B, it is quite likely that
the equivalence relation defined by
these methods is not symmetric.</p>
</blockquote>
<p>I can not post the code here for security violataion. Please let me know what is the error?</p>
|
java
|
[1]
|
2,764,833 | 2,764,834 |
How to convert Alpha-Numeric values in to ASCII values in Android?
|
<p>In my project i want to convert Alpha-Numeric values in to ASCII values and should also convert IMAGE in to ASCII values. Please help me in doing this. Thank u in Advance</p>
<p>edited :</p>
<p>in my project i have some data which is to be printed in a thermal printer. i want to send those data by converting it in to ASCII values via Bluetooth. so please help me</p>
|
android
|
[4]
|
4,776,293 | 4,776,294 |
What does 'v !== v' expression check?
|
<p>I have seen this in the sources of one lib, and confused. I think, it always evaluates to '<code>false</code>'. What is the meaning of using that?</p>
|
javascript
|
[3]
|
3,220,946 | 3,220,947 |
dates interval bigger then it shoud be
|
<p>I have: startDate = 24.03.2013 21:01:20 endDate = 24.03.2013 21:01:40</p>
<p>I do in my code</p>
<pre><code>Date d = new Date(endDate.getTime()-startDate.getTime)
</code></pre>
<p>and d = 01.01.1970 02:00:20 </p>
<p>Where it takes 2 hours, the interval should be 20 seconds, but I get 2 hours and 20 seconds.
Why it happens? What to do with this?</p>
|
java
|
[1]
|
3,670,137 | 3,670,138 |
ChekBox checked always returns false
|
<p>I have a <code>CheckBoxes</code> in a <code>GridView</code>, Now i want to check whether <code>CheckBox</code> is <code>checked</code> or not.</p>
<pre><code><asp:CheckBox ID="cbIsReceived" runat="server" AutoPostBack="true" Checked='<%# Eval("IsReceived") %>' OnCheckedChanged="cbIsReceived_CheckedChanged" cssClass="cbIsReceived"/>
</code></pre>
<p>I am using the following Jquery to see the <code>CheckBox</code> state.</p>
<pre><code>$('.cbIsReceived').live('click', function () {
var result = $(this).is(':checked');
alert(result);
});
</code></pre>
<p>Which always alert false. even if i check it.</p>
<p>Please help.</p>
|
jquery
|
[5]
|
1,361,710 | 1,361,711 |
Random images from array without repeating
|
<p>using:</p>
<pre><code>Image[] icons = { image12, image9, image11, image12, image10, image9, image11, image1, image12, image9, image11, image10, image12, image9, image10, image11, image9, image10, image12, image11 };
for (int i = 0; i < 20; i++)
{
newicon[i] = icons[rnd.Next(0, 19)];
}
</code></pre>
<p>I am attempting to take the list of "icons" and scramble them without repeating them </p>
<p>basically I need
1 image1, 5 image9, 4 image10, 5 image11, and 5 image12's to output, But no more than that amount of each. Everything I have tried ends up with more other images and no image1 or multiple image1's.</p>
<p>I have done this with numbers, which tends not to be a problem, but I can not figure out the images. Also I cant find anything on shuffling images in a list without repeating.</p>
|
c#
|
[0]
|
4,892,845 | 4,892,846 |
php add <br /> only after first 100 characters
|
<p>How to add <code><br /></code> only after first 100 characters? I mean just break once, not add <code><br /></code> after each 100 characters.</p>
<pre><code>$str="Apple has announced that co-founder, former CEO and chairman of the board Steve Jobs has passed away at the age of 56, so we take a look back at the famous innovator's life.At left, Steve Jobs, chairman of the board of Apple Computer, leans on the new 'Macintosh' personal computer following a shareholder's meeting Jan. 24, 1984, in Cupertino, Calif. The Macintosh was priced at $2,495.";
//echo substr($str, 0, 100).'<br />'; this will break sentence after 100 characters.
//echo wordwrap($str, 100, "\n<br />\n");this will add <br /> after each 100 characters.
</code></pre>
<p>And what I need is:</p>
<pre><code>Apple has announced that co-founder, former CEO and chairman of the board Steve Jobs has passed away
<br /> <-- only add here.
at the age of 56, so we take a look back at the famous innovator's life.At left, Steve Jobs, chairman of the board of Apple Computer, leans on the new 'Macintosh' personal computer following a shareholder's meeting Jan. 24, 1984, in Cupertino, Calif. The Macintosh was priced at $2,495.
</code></pre>
|
php
|
[2]
|
2,203,671 | 2,203,672 |
C# Multi line text box error
|
<p>i have created an application, there i have try to save the data from multiline text box to data base. But it will shown a error like
<strong>"String or binary data would be truncated.The statement has been terminated."</strong>
why it will come, what should i do for store data from multiline textbox.</p>
<p>this is the code i have given for store the data for multiline textbox.</p>
<pre><code> cmd.Parameters.AddWithValue("@spec", TextBox3.Text);
</code></pre>
|
c#
|
[0]
|
3,237,744 | 3,237,745 |
Is there a way to change the delete action on an existing instance of shared_ptr
|
<p>I have a function where I want a cleanup action done 90% of the time, but in 10% I want some other action to be done.</p>
<p>Is there some way to use some standard scoped control like<code>shared_ptr<></code> so that initially it can have one delete action and then later in the function the delete action can be changed?</p>
<pre><code>shared_ptr<T> ptr( new T, std::mem_fun_ref(&T::deleteMe) );
ptr.pn.d = std::mem_fun_ref(&T::queueMe);
</code></pre>
|
c++
|
[6]
|
5,344,096 | 5,344,097 |
Listview of installed apps on android
|
<p>I want to make a list view that shows the name and icon of all applications in user's device i found some codes but i don't know how to use them or what do they mean please help me to make a list because that's my biggest problem :)</p>
|
android
|
[4]
|
510,008 | 510,009 |
How do I paint Pictureboxes to Panel?
|
<p>I have 2 pictureboxes on a panel at two separate locations which will become Hidden after a certain time. I would like to paint the pictureboxes background image to the panel at the exact points in which the picturebox controls lay. I have looked at the MSDN library but I cannot seem to find out how to do this.</p>
<p>Thanks for any help</p>
|
c#
|
[0]
|
789,079 | 789,080 |
How to handle concurrency in an ASP.Net WebSite? (auctioneer site)
|
<p>my problem is follow: </p>
<p>I have an auctioneer site, in which many different objects will be auctioneerd.</p>
<p>My problem is very simple to clear for an more experience user I thinK. How I can handle business and database logic without opened a site or them?</p>
<p>My problem is to say directly, if nights at 3 no user is on the site, the winner (e.g.) must be set - if a page is opened or not.</p>
<p>So I need some kind of "every 2 seconds, do this method" - without opened a site.</p>
<p>My idea was a sepereate application which uses the same business and database-layer as the asp.net page and let this run at the server. Is that a good or bad idea?</p>
|
asp.net
|
[9]
|
3,189,699 | 3,189,700 |
Formating numbers with %1$,.2f
|
<p>I am using </p>
<pre><code>public static String displayNumberAmount(Number amount, Locale locale) {
String.format(locale, "%1$,.2f", amount);
}
</code></pre>
<p>to format my numbers in locale and 2 decimals.</p>
<p>If i have number 1032 it will be correctly formatted into the 1 032,00
BUT if I have number lower than 1000, for example 890, it will be formatted as 890 (and I need those 2 decimals always)</p>
<p>in the object, those values are stored as BigDecimals, like </p>
<pre><code>BigDecimal val = object.getAmount();
String formattedVal = displayNumberAmount(val, myLocale);
</code></pre>
<p>Can you tell me why? </p>
|
java
|
[1]
|
5,338,687 | 5,338,688 |
android: OnEditorActionListener stops the app
|
<p>Please when I try to run this app it stops.</p>
<p>The problem is with OnEditorActionListener, if i delete the app loads and runs ok.</p>
<pre><code>import android.app.Activity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.TextView.OnEditorActionListener;
import android.widget.Toast;
public class IMEDemo2 extends Activity
{ EditText et;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
et.setOnEditorActionListener(new OnEditorActionListener() {
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
}
Toast.makeText(getApplicationContext(), "OK", Toast.LENGTH_LONG).show();
return true;
}
});
}
</code></pre>
<p>}</p>
|
android
|
[4]
|
4,339,590 | 4,339,591 |
Check if values exits in database
|
<p>I want to check if a couple of values exists in the database. If they do, the method should return TRUE or FALSE if the cursor is null. But the problem is that it returns TRUE all the time despite the values are not in the database! What have I missed? </p>
<pre><code> // This method check if the combination image path and contact name already exists in database
public boolean checkContentDatabase(String imageFilePath, String contactName) {
String query = "Select * from " + DB_TABLE+ " where " + TABLE_IMAGE_PATH + "='" + imageFilePath + "' and " + TABLE_CONTACT_NAME + "='" + contactName +"' ;";
Cursor c = db.rawQuery(query, null);
if(c != null) // Exists in database
{
return true;
}
else
{
return false;
}
}
</code></pre>
|
android
|
[4]
|
386,781 | 386,782 |
Best way to create a graph from data
|
<p>I have some data, let's say the number of sells of the month. I want to create a discrete graph showing the amount of sold items every day.</p>
<p>The only way i'm able to do that is creating some CGRects, and then load subviews with these rects as frame, and color their backgrounds. So the columns of the graph are made by small, colored view.</p>
<p>Do you think this could be the right way? Or do you think there are better approaches? </p>
|
iphone
|
[8]
|
819,931 | 819,932 |
How to convert javascript date to GMT milliseconds?
|
<p>I have the following date:</p>
<pre><code>var datestr = "11/11/2012 10:55"
</code></pre>
<p>When I do the following:</p>
<pre><code>var datems = new Date(datestr).getTime();
</code></pre>
<p>The milliseconds I get do not appear to be the correct milliseconds as it appears to be much farther ahead in time. How do i convert the "datestr" above to milliseconds (in respect to GMT)?</p>
|
javascript
|
[3]
|
1,742,401 | 1,742,402 |
How to debug android quickly?
|
<p>When I modify some code, I need to operate the virtual machine again. It is cost too much time.</p>
<p>Who knows some good method to debug the code quickly?</p>
|
android
|
[4]
|
3,940,493 | 3,940,494 |
why can't we declare object of a class inside the same class?
|
<pre><code>class A
{
A a;//why can't we do this
};
</code></pre>
|
c++
|
[6]
|
1,238,206 | 1,238,207 |
c# collections and grabbing property value of each into a new array
|
<p>I have a list of objects each with its own id property. I need to create an icollection of ids from the stored objects. Is there an elegant way other than looping through the list of objects, grabbing the id value and dumping it into the collection?</p>
<p>Thanks in advance</p>
|
c#
|
[0]
|
123,661 | 123,662 |
hide div if it contains no text
|
<p>If <code>PageHeaderDescription</code> contains no text content then I want to hide it. Is it possible with jquery?</p>
<pre><code><div class="PageHeaderDescription">
<h1>Accessories</h1>
<img border="0" src="" style="cursor: pointer; display: none;" id="EntityPic621">
</div>
</code></pre>
<p>This is what the div looks like with text:</p>
<pre><code><div class="PageHeaderDescription">
<h1>Accessories</h1>
<img border="0" src="" style="cursor: pointer; display: none;" id="EntityPic621">
This is the Accessories page, you can find stuff for the products!
</div>
</code></pre>
|
jquery
|
[5]
|
2,002,576 | 2,002,577 |
Name mangling of c++ classes and its member functions?
|
<p>Is there no way I could avoid name mangling of C++ classes and its member functions when exposed from a c++ dll. </p>
<p>Can't I use a def file mechanism in this regard ?</p>
|
c++
|
[6]
|
4,251,952 | 4,251,953 |
Stream was not readable - nothing is disposed of, why does this not work?
|
<p>I have the following code:</p>
<pre><code> // Create POST data and convert it to a byte array.
string postData = "name=t&description=tt";
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
// Set the ContentType property of the WebRequest.
request.ContentType = "application/x-www-form-urlencoded";
// Set the ContentLength property of the WebRequest.
request.ContentLength = byteArray.Length;
// Get the request stream.
using (StreamReader reader1 = new StreamReader(request.GetRequestStream()))
{
string s = reader1.ReadToEnd();
}
</code></pre>
<p>Ignore the naming convention (e.g. reader1), as I am trying to adjust the code to make it work. Anyway, when the flow hits the using (..... ) statement, I get the following exception:</p>
<p>Stream was not readable</p>
<p>I want to read the entire request stream into a string, nothing is closed, so the code should work?</p>
<p>Thanks</p>
|
c#
|
[0]
|
3,323,309 | 3,323,310 |
how to call sqlsrv_fetch_array(..) multiple times?
|
<p>I have a command like..</p>
<pre><code>$Res = $db->ExecSQL($sQry, $param);
while ($row = sqlsrv_fetch_array($Res)){
..
..
}
</code></pre>
<p>and i wanted to call again the </p>
<pre><code>while ($row = sqlsrv_fetch_array($Res)){
..
..
}
</code></pre>
<p>without calling again the "$Res = $db->ExecSQL($sQry, $param);"
because it has no result. there must be a reset like pointing it to the first record. but i dont know how. any suggestion?</p>
|
php
|
[2]
|
962,292 | 962,293 |
Iphone apps development
|
<p>I'm very keen to learn Iphone apps development. Can you experts give me some tips as to which programing tool I should learn? tools I should install [of course , I prefer free tools]?, operating system I need? [I only have windows xp and unix flavours on my Personal laptop]. Do I need to have Iphone to test my apps? [poor guy, I don't own a Iphone].</p>
<p><strong>Thanks to all who responded , every message seems very informative and useful (+1 to all), I will go through each and every suggestion</strong></p>
|
iphone
|
[8]
|
2,778,023 | 2,778,024 |
Find an element in a list of tuples
|
<p>I have a list 'a'</p>
<pre><code>a= [(1,2),(1,4),(3,5),(5,7)]
</code></pre>
<p>I need to find all the tuples for a particular number. say for 1 it will be</p>
<pre><code>result = [(1,2),(1,4)]
</code></pre>
<p>How do I do that. </p>
<p>PS - This is not homework</p>
|
python
|
[7]
|
5,660,885 | 5,660,886 |
how to create an empty zip archve by php
|
<p>how to create an empty zip archve by php
some thing like
new -> zip archive</p>
|
php
|
[2]
|
2,386,100 | 2,386,101 |
How to get a particular value from innerhtml in Javascript?
|
<p>Recently I am working with project a in which i want the value of <code>#page='+pid+'"</code>
from this embeded code of <code>innerhtml</code>. I have tried with index as position, but dit not get the desired result.
There is pageid value, which I want. I have also tried this:</p>
<pre><code>var aPosition = aURL.indexOf(pid);
var res =aURL.charAt(aPosition)</code>
var aURL=document.getElementById('pdffile').innerHTML='<embed src="../EyeLegalAdmin/wp-content/plugins/EyeLegalAdmin/Data/<?=$_GET['CaseId']?>/<?=$_GET['file']?>#page='+pid+'" type="application/pdf" height="618px" width="100%" onScroll="yes" />';`
</code></pre>
<p>How can I go about this?</p>
|
javascript
|
[3]
|
981,823 | 981,824 |
Easy way to change value of bolean
|
<p>A lot of time I have inverse logic between my forms and data, I am looking for easiest (most elegant) way to change some boolean from true to false and vice versa.<br>
I know that a lot of people will get angy if see code like this:</p>
<pre><code>if (c)
{
return false;
}
else
{
return true;
}
</code></pre>
<p>Or something like this</p>
<p>EDIT:</p>
<p>I am sorry, My mistake My code sample is not good.<br>
What I need to do If I vont just to use inverse value of Boolean </p>
<pre><code>myMethod(!op.checkBoxSamoSaKol.Checked) // Is this possibile
</code></pre>
|
c#
|
[0]
|
315,518 | 315,519 |
How to make modifications on a subset of elements in a list
|
<p>oldUsers is just a subset of allUsers and all oldUsers are made in-active in the following list. The logic currently works, but I am iterating allUsers just to get the handle of oldUser every time, before I set the active flag to false. Is there a way to pull the appropriate record and make my modifications (oldUsers and allUsers is of type <code>Set<User></code>)</p>
<pre><code>for (User oldUser : oldUsers) {
for (User user : allUsers) {
if (user.getId().equals(oldUser.getId())) {
user.setActive(false);
}
}
}
</code></pre>
|
java
|
[1]
|
1,272,359 | 1,272,360 |
Jquery : find text from string which is not in DIV tag
|
<pre><code>if x = 'FName LName<div class="soc-net-not" id="social_network_notification_853">3</div>';
</code></pre>
<p>How do I extract only the portion 'FName LName' from the above string. I dont want div tags or its innerHTML</p>
|
jquery
|
[5]
|
2,162,540 | 2,162,541 |
iPhone SDK: Store Kit: Can I host the downloads on my own server?
|
<p>I want to make an app where every single item is unique. I could not find out much information about the Store Kit in iPhone OS 3.0. Do I have to upload all these download-items to the App Store? Or can the download be made from my own server? </p>
<p>Example:
I have 10 items in my app that people can buy. They are highly exclusive, so the one who buys item X, will be the only one who's got that item. after the purchase it's not available anymore.</p>
<p>Do you think it is possible to do that?</p>
|
iphone
|
[8]
|
5,460,854 | 5,460,855 |
Export data into Excel, Word and PDF with Formatting
|
<p>I want to export data of DataTable or DataSet with formating like Color of Header-Footer, Font Size, Row Color in Word, Excel and PDF format. Is it possible?</p>
<p>If yes then how? Please healp me.
My code is as below.</p>
<pre><code>public void ExportToExcel(DataTable dt)
{
con.Open();
string sql = "select *from test";
cmd = new SqlCommand(sql, con);
dt = new DataTable();
da = new SqlDataAdapter(cmd);
da.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
cmd.Dispose();
string filename = "DownloadTest.xls";
System.IO.StringWriter tw = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw);
DataGrid dgGrid = new DataGrid();
dgGrid.DataSource = dt;
dgGrid.DataBind();
DataSet ds = new DataSet();
ds = dt.Clone;
dgGrid.RenderControl(hw);
Response.ContentType = "application/vnd.ms-excel";
Response.AppendHeader("Content-Disposition", "attachment; filename=" + filename + "");
this.EnableViewState = false;
Response.Write(tw.ToString());
Response.End();
con.Close();
}
</code></pre>
|
asp.net
|
[9]
|
4,398,200 | 4,398,201 |
access a model from another model in Entity Framework
|
<p>Can i access an entity of a model from another model?
when each model is an EDMX file.
Why i want to use multiple models?
because i have a Database dependent model and an independent model </p>
<pre><code>i don't want to update the independent one while updating the dependent model from Database
</code></pre>
<p>thanks for reading.</p>
|
c#
|
[0]
|
120,309 | 120,310 |
Pass an object as parameter in PHP
|
<p>In Java, I can pass an object straight in parameter </p>
<pre><code>public int foo (Bar bar)
{
... call the methods from Bar class
}
</code></pre>
<p>So how can I do same thing with PHP. Thanks
This is my code:</p>
<pre><code>class Photo
{
private $id, $name, $description;
public function Photo($id, $name, $description)
{
$this->id = $id;
$this->name = $name;
$this->description = $description;
}
}
class Photos
{
private $id = 0;
private $photos = array();
private function add(Photo $photo)
{
array_push($this->photos, $photo);
}
public function addPhoto($name, $description)
{
add(new Photo(++$this->id, $name, $description));
}
}
$photos = new Photos();
$photos->addPhoto('a', 'fsdfasd');
var_dump($photos); // blank
</code></pre>
<p>If I change the function add</p>
<pre><code>function add($name, $description)
{
array_push($this->photos, new Photo(++$this->id, $name, $description));
}
</code></pre>
<p>It works pefectly. So What is wrong ?</p>
|
php
|
[2]
|
2,283,325 | 2,283,326 |
Manipulating Multi dimension array
|
<p>I have a Multi dimension array and what i 'd like to do is put array to insert the element in each column </p>
<p>for example</p>
<p>Multi dimension array :</p>
<pre><code>Tony 14
Peter 20
</code></pre>
<p>I would like to insert them into a different array , so that</p>
<pre><code>column0[]={Tony, Peter}
column1[]={14, 20}
</code></pre>
<p>Since i do not know the actual no of column , how can i achieve this?</p>
<pre><code> for ($row = 1; $row <= $highestRow; $row++) {
for ($y = 0; $y < $highestColumn; $y++) {
................what should be added here................
}
}
</code></pre>
<p>Thank you</p>
|
php
|
[2]
|
386,257 | 386,258 |
How to select image with .jpg
|
<p>Is there any way I can target images with .jpg?</p>
<p>For example, the following code enlarge all the image. However I want to enlarge only .jpg.</p>
<pre><code>/*
* If a page url contains /art-8 (not cart-8), then do this.
* Add a link to zoom an image on the first image on a product page
*/
if (/[^c]art-8/.test(location.pathname)) {
$("#system #product_cont img").wrapAll("<ul class=\"cont_thumb\">").wrap("<li>");
$(".cont_thumb").after("<div style='clear:both;padding-bottom: 20px;'></div> ");
$("ul.cont_thumb li").hover(function(){
$(this).css({
'z-index': '10'
});
$(this).find('img').addClass("hover").stop().animate({
marginTop: '0px',
marginLeft: '-35px',
top: '50%',
left: '50%',
width: '344px',
height: '258px',
padding: '0px'
}, 200);
}, function(){
$(this).css({
'z-index': '0'
});
$(this).find('img').removeClass("hover").stop().animate({
marginTop: '0',
marginLeft: '0',
top: '0',
left: '0',
width: '80px',
height: '60px',
padding: '3px'
}, 400);
});
</code></pre>
|
jquery
|
[5]
|
1,719,800 | 1,719,801 |
how to pass javascript variables from one javaScript page to another javascript page?
|
<p>I have two javascript files in one folder.I want to pass a variable one javascript file to another.what procedure should I use?</p>
|
javascript
|
[3]
|
3,304,568 | 3,304,569 |
How to know if tomcat is running (and its port number) on my windows machine?
|
<p>I am running a c# application and I need to know whether Apache Tomcat is running or not and also know the port for it.</p>
<p>There are multiple ways Tomcat is installed. In certain installations, I get the service in the Services list while in some I do not.</p>
<p>Can somebody help me?</p>
|
c#
|
[0]
|
554,995 | 554,996 |
What's the point of the NOT operator?
|
<p>Currently checking out C++ using <a href="http://www.cprogramming.com/tutorial/lesson2.html">this tutorial</a>. It explains what the <code>! NOT</code> operator is, kind of, but I don't think I fully understand why I'd ever want to use it. Can someone please explain?</p>
|
c++
|
[6]
|
3,927,923 | 3,927,924 |
iPhone GUI for real-time log message display
|
<p>My goal is to have a screen on my GUI dedicated to logging real-time messages generated by my internal components. A certain limit will be set on the log messages so that older messages are pruned. </p>
<p>I'm thinking about implementing using a <code>UITextView</code> with a <code>NSMutableString</code> to store the output. I would have to perform manual pruning somehow on the <code>NSMutableString</code> object. Is a better way to implement this?</p>
|
iphone
|
[8]
|
922,882 | 922,883 |
Killing app <my service> (pid 1724) because provider <my provider> is in dying process <my app>
|
<p>A Provider is implemented in application and application updates provider data and triggers a remote service which queries the provider to retrieve the stored values.The application is closed after sometime but service keep on accessing the content provider.At some point the following error is thrown in logcat and the remote service is crashed.</p>
<p>"Killing app (pid 1724) because provider is in dying process "</p>
<p>I googled for this error and couldn't find information about why this error occurs.</p>
<p>UPDATE: In one of the places context returned by getApplicationContext is used instead of Service to get contentresolver to query the content provider. Does it cause any problem? </p>
|
android
|
[4]
|
3,265,611 | 3,265,612 |
hover fade in not executing
|
<p>I'm decently knew to understanding the language that is jquery. I'm competent in HTML and CSS but this seems to be a higher learning curve than I have. </p>
<p>This is the code I plan to implement:
<a href="http://jsfiddle.net/yuQqh/15/" rel="nofollow">http://jsfiddle.net/yuQqh/15/</a></p>
<p>The fade in hover function isn't rendering and I'm not sure how to fix it.
Basically there are list items and the hovered list link should fade in to reveal the content of the list item's sub box, and then fade out when not hovered upon.</p>
<p>Thanks.</p>
|
jquery
|
[5]
|
3,311,840 | 3,311,841 |
Live audio streaming with Android 2.x
|
<p>I need to play a live stream on devices with 2.x and greater versions. <a href="http://developer.android.com/guide/appendix/media-formats.html" rel="nofollow">This</a> states that it's impossible to play live streams on devices with Android 2.x.</p>
<p>What're my options here ? Especially I'm interested in streaming audio - what format should i pick and in conjunction with which protocol ?</p>
<p>P.S. I've tried Vitamio - don't want to make customers download third party libraries.</p>
<p><strong>UPD</strong> </p>
<ul>
<li>How come I can play this stream "http://188.138.112.71:9018/" ?</li>
</ul>
|
android
|
[4]
|
3,883,694 | 3,883,695 |
How to assign indexes to variable names inside FOR LOOP?
|
<p>How to assign indexes to variable names? For instance, project0, project1, project2, etc?</p>
<pre><code>for (var i=0; i<data.length; i++)
{
var project+i = new GanttProjectInfo(1, "Applet redesign", new Date(2010, 5, 11));
var parentTask+i = new GanttTaskInfo(1, "Old code review", new Date(2010, 5, 11), 208, 50, "");
project1.addTask(parentTask+i);
// Load data structure
ganttChartControl.addProject(project+i);
// Build control on the page
}
</code></pre>
|
javascript
|
[3]
|
2,608,598 | 2,608,599 |
what is causing Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 5
|
<pre><code>public static void sumrowsandcols(int[][] a) {
int[] sum = new int[5];
int i, j, x;
// Sum of rows
for (i = 0; i < 5; i++) {
for (j = 0; j < 5; j++) {
sum[i] += a[i][j];
}
}
for (x = 0; x < 5; x++) {
System.out.println(sum[x]);
}
// Sum of columns
for (i = 0; i < 5; i++) {
for (j = 0; j < 5; j++) {
sum[i] += a[j][i];
}
}
for (x = 0; x < 5; x++) {
System.out.println(sum[x]);
}
}
public static int[][] generateArray(Scanner myScanner) {
int numbers[][] = new int[5][5];
int i, j, x;
for (i = 0; i < 5; i++)
System.out.println("Please enter 5 integers for row " + (i+1));
for (x = 0; x < 5; x++) {
j = myScanner.nextInt();
numbers[i][x] = j;
}
return numbers;
}
// Main method. Collection happens, then calls sumrowsandcols.
public static void main(String[] args) {
int i, j, x;
Scanner myScanner = new Scanner(System.in);
int[][] numbers = generateArray(myScanner);
// Collect information by row
// Print sum of rows and columns
sumrowsandcols(numbers);
}
</code></pre>
|
java
|
[1]
|
5,831,723 | 5,831,724 |
PHP not be able to echo data
|
<blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/7048618/php-not-be-able-to-echo-data">PHP not be able to echo data</a> </p>
</blockquote>
<p>I'm trying to get data from database, and echo them on the page using their unique id.. below is my code</p>
<pre><code><?php
session_start();
require_once('config.php');
//create query statement
$query = 'SELECT * FROM player_info';
//make the query from db
$myData = mysql_query($query, $conn)
OR exit('Unable to select data from table');
while($row = mysql_fetch_array($myData, MYSQL_ASSOC)){
$playerID = $row['id'];
$player_bio = $row['player_bio'];
$achievements = $row['player_achts'];
}
</code></pre>
<p>?></p>
<p>and here is how i code for echo the data</p>
<pre><code><?php
if ($playerID == 1)
{
echo '<p class="playerAchievesL">' . $achievements . '</p><p class="playerInfoL">' . $player_bio . '</p>';
}
?>
</code></pre>
<p>I don't get any error return from php, but the data does not display anything... help please ... thank you so much</p>
|
php
|
[2]
|
3,172,555 | 3,172,556 |
Join strings for series of nested lists in Python 2.7.2
|
<p>I have a series of lists that contain an integer and a nested list with multiple strings. The goal is to join the strings into one string. I have accomplished this with code that works on one list. The problem is when I try to iterate over the series of lists there is an error: "TypeError: sequence item 0: expected string, int found." I have tried to change the integer to a string, ignore items that are integers and direct the code to the nested list without success. </p>
<p>Example of series:</p>
<pre><code> [19497, ['83', 'CLM']]
[19498, ['80', 'COS', 'PAN', '83', 'CLM']]
[19505, ['79', 'MXE', 'MXN', 'MXS']]
[19507, ['83', 'CLM', 'ECU']]
[19509, ['79', 'MXG', 'MXS', 'MXT', '80', 'BLZ', 'GUA', 'HON', 'NIC']]
</code></pre>
<p>This works for one list:</p>
<pre><code> >>> q = [48, ['40', 'ASS', 'EHM', 'IND', 'NEP', 'WHM', '41', 'MYA']]
>>> q[1] = " ".join(q[1])
>>> q
[48, '40 ASS EHM IND NEP WHM 41 MYA']
</code></pre>
<p>This is what I tried for the iteration and get the type error.</p>
<pre><code> def smush(q):
'''STILL IN PROGRESS: Trying to create single string in nested list.'''
for line in q:
q[1] = ' '.join(q[1])
return q
</code></pre>
<p>I have a feeling there is a simple solution to this I have overlooked. Suggestions? </p>
<p>Thanks for any help you can provide.</p>
|
python
|
[7]
|
213,712 | 213,713 |
Fonts used on Android OS Gallery
|
<p>What fonts / sizes are used for the date, gallery name, and number of items when viewing a gallery on the Android OS?</p>
|
android
|
[4]
|
2,770,858 | 2,770,859 |
Can I use jQuery to animate properties independently?
|
<p>I would like to animate the sizes and position of elements independently in the interest of being able to use jQuery's <code>stop()</code> function to clear the queue for one property but not the other. I am only animating the <code>width</code> and <code>left</code> properties.</p>
<p>Is there a way of accomplishing this?</p>
|
jquery
|
[5]
|
559,490 | 559,491 |
check for valid arguments
|
<p>So let's define a few functions:</p>
<pre><code>def x(a, b, c): pass
def y(a, b=1, c=2): pass
def z(a=1, b=2, c=3): pass
</code></pre>
<p>Now, what's the best way to, given a pointer to <code>x</code>, <code>y</code>, or <code>z</code> (<code>p</code>), a tuple of args (<code>a</code>) and a dictionary of kwargs (<code>k</code>), check to see if </p>
<pre><code>p(*a, **kw)
</code></pre>
<p>would produce any exception regarding having not enough arguments or incorrect arguments, etc—<em>without</em> actually calling <code>p(*a, **kw)</code> and then catching the exceptions raised.</p>
<h2>Example</h2>
<pre><code>def valid(ptr, args, kwargs): ... #implementation here
valid(x, ("hello", "goodbye", "what?"), {}) # => True
valid(x, ("hello", "goodbye"), {}) # => False
valid(y, ("hello", "goodbye", "what?"), {}) # => True
valid(y, (), {"a": "hello", "b": "goodbye", "c": "what"}) #=> True
valid(y, ("hello", "goodbye"), {"c": "what?"}) #=> True
</code></pre>
|
python
|
[7]
|
776,402 | 776,403 |
javascript stream wrapper, intercept JS file contents
|
<p>In PHP there's a function called <strong>stream_wrapper_register</strong>. With that i can get the file contents of every PHP file that is about to be included. So that basically gives me control over the 'code' that will get parsed.</p>
<p>I was wondering if there's something like this in javascript too? So suppose i include my file:</p>
<pre><code><script type="text/javascript" src="js/myfile.js"></script>
</code></pre>
<p>My code in that file then sets up the stream wrapper (suppose this is available in JS too). Now i want to be able to get the file contents of every other javascript file that will be included:</p>
<pre><code><script type="text/javascript" src="js/somefile.js"></script>
<script type="text/javascript" src="js/someotherfile.js"></script>
</code></pre>
<p>But this ofcourse must happen before before the browser actually executes those files.</p>
<p>So is there a way to intercept that somehow?</p>
|
javascript
|
[3]
|
5,123,795 | 5,123,796 |
MediaPlayer doens't work properly
|
<p>In my app i added a sound when a button is clicked</p>
<p>This is the class that manages the sound</p>
<pre><code>public class GestoreSuoni{
MediaPlayer mp;
public void playSound(Context context,int sound){
mp = MediaPlayer.create(context, sound);
mp.start();
}
}
</code></pre>
<p>and in my main activity I call the method playSound for all of my buttons </p>
<pre><code>button_name.setOnClickListener(new OnClickListener(){
public void onClick(View arg0) {
gestoreSuoni.eseguiSuono(getApplicationContext(),R.raw.tieni_suono);
}
});
</code></pre>
<p>At first it works, but after 20-30 clicks on my buttons, I can't hear sound anymore and i get this message from LogCat: Mediaplayer error (- 19,0).</p>
<p>What does is mean?</p>
<p>Thanks</p>
|
android
|
[4]
|
1,605,515 | 1,605,516 |
Copy Event To Cloned Contorl
|
<p>i have this method in asp.net for clone my control : </p>
<pre><code>public static Control Clone( Control ctrlSource )
{
Type t = ctrlSource.GetType();
Control ctrlDest = ( Control )t.InvokeMember( "" , BindingFlags.CreateInstance , null , null , null );
foreach( PropertyInfo prop in t.GetProperties() )
{
if( prop.CanWrite )
{
if( prop.Name == "ID" )
{
ctrlDest.ID = ctrlSource.ID + "cloned" + Security.Cryptography.Cryptography.generateRandomPrivateKey( 5 );
}
else
{
prop.SetValue( ctrlDest , prop.GetValue( ctrlSource , null ) , null );
}
}
}
return ctrlDest;
</code></pre>
<p>}</p>
<p>how can i set the source control event(like Click event) in destination control?</p>
|
asp.net
|
[9]
|
5,328,617 | 5,328,618 |
startActivity() but do not show it
|
<p>I have a media player app and I am trying to handle events such as when you receive a phone call. I can get it stopped properly and kill the service. Then I need to switch back to the main activity so when the user gets done with their phone call they can re-select a station to play. The problem I have is when I switch the activity with startActivity(intent) it gets shown in front of the phone dialer--this is not a good user experience.
So how can I get my app reset back to the correct activity without it showing in front of another app?</p>
<pre><code>private BroadcastReceiver phoneReceiver = new BroadcastReceiver()
{
@Override
public void onReceive(Context context, Intent intent)
{
//stop the play service
Intent stopPlayingService = new Intent(context, Play.class);
stopService(stopPlayingService);
//switch back to the main screen
Intent showMain = new Intent(context, MouseWorldRadioActivity.class);
showMain.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//showMain.addFlags(Intent.); not sure whats needed here
startActivity(showMain);
}
};
</code></pre>
|
android
|
[4]
|
5,100,516 | 5,100,517 |
HttpModules Configuration error
|
<p>1- I have a class structure as shown below.</p>
<pre><code>namespace ViewStateSeoHelper
{
class ViewStateSeoModule : IHttpModule
{
public void Init(HttpApplication context)
{
context.BeginRequest += new EventHandler(context_BeginRequest);
}
void context_BeginRequest(object sender, EventArgs e)
{
HttpApplication application = sender as HttpApplication;
if (application.Context.Request.Url.AbsolutePath.Contains(".aspx"))
application.Response.Filter = new HtmlFilterStream(application.Response.Filter);
}
public void Dispose()
{
}
}
}
</code></pre>
<p>I'm using something like this to using in all those pages through upper code.</p>
<pre><code><httpModules>
<add name="ViewStateSeoModule" type="ViewStateSeoModule" />
</httpModules>
</code></pre>
<p>But,I got the configuration error.</p>
<pre><code>Parser Error: Could not load type 'ViewStateSeoModule'.
(C:\Users\xxx\Documents\Visual Studio 2010\WebSites\xxx\web.config line 78)
Line 78: <add name="ViewStateSeoModule" type="ViewStateSeoModule" />
</code></pre>
<p>Thanks in advance.</p>
|
asp.net
|
[9]
|
1,256,402 | 1,256,403 |
Execute PHP code when making a post in a cms
|
<p>Sorry for the vague title but it's hard to describe what I mean in a few words.</p>
<p>I made my own cms and use it for all my personal projects. On some pages I want to include a php script in the content area. I load the content simply by echoing the variable that holds the content.</p>
<p>The template file looks like this:</p>
<pre><code><div id="content">
echo $content;
</div>
</code></pre>
<p>In my CRUD I make a post containing a php snippet.</p>
<pre><code><?php echo "My name is ".$var.""; ?>;
</code></pre>
<p>Then I save it and load the page and this is what happens:</p>
<pre><code><div id="content">
echo <?php echo "My name is ".$var.""; ?>;
</div>
</code></pre>
<p>But what I want is that the php code get's executed instead of getting echoed.
Something like the Wordpress plugin Exec-PHP. Can anybody explain to me how to achieve this?</p>
<p>Thanks in advance!</p>
|
php
|
[2]
|
2,273,470 | 2,273,471 |
Get event of Home key long press when screen is locked?
|
<p>I am developing an application in which I have to control the Home key long press when the screen is in locked mode to perform an action.Is there any possible way to do this.Please help me..</p>
|
android
|
[4]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.