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 |
|---|---|---|---|---|---|
2,986,867 | 2,986,868 | Form a binary number from drop down lists | <p>So,
I have 8 drop down lists that are populated with the values 0 and 1. With the selected values from those 8 drop down lists, I want to put them together to make a binary number.
From there I'd convert the binary number to a decimal(the decimal output would be displayed in a textbox, so the decimal number would change everytime a different number in any of the drop down lists is changed).</p>
<p>But I'm unsure of how to get all 8 of the selected values combined to make an 8-bit binary number so I can convert it once I get that number. Any suggestions on how I should start this?</p>
| c# | [0] |
3,586,387 | 3,586,388 | variable in variable in php | <pre><code>$var="profile['Gamer']['last_name']";
echo ${$var};
</code></pre>
<p>Gives </p>
<blockquote>
<p>Undefined variable: profile['Gamer']['last_name']</p>
</blockquote>
<p>. But if i try to echo $profile['Gamer']['last_name'] value exist </p>
<p>I have tried echo $$var that too didn't work</p>
| php | [2] |
4,956,933 | 4,956,934 | How do I get the taskbar's position and size? | <p>I want to know how to get the rectangle (bottom, top, left, and right) that the taskbar occupies. How do I go about doing this in C#?</p>
| c# | [0] |
3,454,680 | 3,454,681 | What is wrong with this syntax? | <pre><code> public static void PullData(Hashtable source)
{
IPGlobalProperties ipProperties = IPGlobalProperties.GetIPGlobalProperties();
//IPEndPoint[] endPoints = ipProperties.GetActiveTcpListeners();
TcpConnectionInformation[] tcpConnections = ipProperties.GetActiveTcpConnections();
foreach (TcpConnectionInformation info in tcpConnections)
{
if (!(info.RemoteEndPoint.Address.ToString() == "192" || info.RemoteEndPoint.Address.ToString() == "127"))
{
source.Add(info.RemoteEndPoint.Address.ToString(), new IPInstance(
new string[info.LocalEndPoint.Port.ToString(), info.RemoteEndPoint.Port.ToString()],
info.RemoteEndPoint.Address.ToString(),
Dns.GetHostEntry(info.RemoteEndPoint.Address.ToString())
));
}
}
}
</code></pre>
<p>I keep getting Error 1 Cannot implicitly convert type 'string' to 'int'</p>
| c# | [0] |
5,626,821 | 5,626,822 | Can PHP analyze another web page? | <p>I'm making a search engine that (in theory) analyzes online encyclopedias to get answers to a user's question from a form. However, I want to know if I'm wasting my time with the PHP. If I am, what language would be best suited to this task? If I'm not, what function in PHP would allow me to do this? Thanks!</p>
| php | [2] |
3,921,659 | 3,921,660 | Header redirect and Session start() generating errors | <p>I am using following code. I get errors:</p>
<p>Warning: Cannot modify header information - headers already sent by (output started at /home/public_html/mc/cpanel/Source/verifylogin.php:11)</p>
<p>Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/public_html/mv/cpanel/Source/verifylogin.php:11)</p>
<p>Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/public_html/mv/cpanel/Source/verifylogin.php:11) </p>
<pre><code><?php
error_reporting(E_ALL^ E_NOTICE);
ob_start();
require("../Lib/dbaccess.php");
$inQuery = "SELECT mhuserid, mhusername FROM cpanelusers WHERE mhusername = '". $_POST['UserName'] ."' AND mhpassword = '". hash('sha512', $_POST['Password']) ."'";
try
{
$Result = dbaccess::GetRows($inQuery);
echo $Result;
$NumRows = mysql_num_rows($Result);
if ($NumRows > 0)
{
header("Location: http://www.example.com/cpanel/mainwindow.php");
session_start();
}
else
{
header("Location: http://www.example.com/cpanel/");
echo "Last login attempt failed.";
exit;
}
}
catch(exception $e)
{
}
ob_clean();
?>
</code></pre>
| php | [2] |
3,572,610 | 3,572,611 | trying to reference config file in different project | <p>My test file is in the project at the following folder:</p>
<pre><code>C:\path1\path2\path3\path4\Tests\Unit\MyUnitTest.cs
</code></pre>
<p>My config file is in the project in the following folder:</p>
<pre><code>C:\path1\path2\Web\configs\myprecious.config
</code></pre>
<p>How do I reference my config file in the MyUnitTest.cs file as a relative path? Currently I am hardcoding it as <code>C:\path1\path2\Web\configs\myprecious.config</code> which is not correct.</p>
<p>Please let me know.</p>
<p>Thanks..</p>
<p><strong>EDIT</strong>: </p>
<p>I solved it by reference it as follows:</p>
<p>Web\configs\myprecious.config</p>
| c# | [0] |
5,531,188 | 5,531,189 | jQuery custom functions | <p>Why the value of <code>oldHeight</code> is not overridden ? It still has <code>oldHeight</code> to <code>80</code> not what i have passed as argument. Even if i pass argument <code>newHeight</code>, it will also not override it. But according to the <a href="http://docs.jquery.com/Plugins/Authoring" rel="nofollow">documentation</a>, it will automatically updated. Here's the code:</p>
<pre><code>( function($) {
$.fn.bad = function(callback) {
var options;
var settings = $.extend({
"oldHeight":"80",
"newHeight":"200"
}, options);
return this.each( function() {
var that$ = $(this);
that$.bind("mouseenter", function() {
$(this).animate({ "height" : settings.newHeight+"px" });
}).bind("mouseleave", function() {
$(this).animate({ "height" : settings.oldHeight+"px" });
});
});
}
})(jQuery);
$(".box").bad({"oldHeight":"400"});
</code></pre>
<p>And this ===> <a href="http://jsfiddle.net/cGSNn/" rel="nofollow"><code>Fiddle</code></a></p>
| jquery | [5] |
3,195,086 | 3,195,087 | How to create multiple objects based on frequency and date | <p>for some reason, I am unable to figure how to code it in a clean way.
I have a task object and this object has a start date and end date. I want to pass this object to method that will take this task, clone it X number of times according to the frequency and set its start date to the occurance date.</p>
<p>Offcourse, things can be much better illustrated by examples:
So lets say I have task that has start date of June 1 ,2012 and end date of September 15, 2012. The frequency is set to monthly. I want to pass this task to a method that would create an array of 4 tasks for me (June, July, Aug, September) of whose the start date is set to the first of the respective month</p>
<pre><code>ArrayList<task> spawnTasks(Task task, Frequency Monthly){
ArrayList<Task> arr = new ArrayList<Task>();
Task TaskJune = task.clone();
TaskJune.setStartDate("June, 1, 2012");
Task TaskJuly = task.clone();
TaskJuly.setStartDate("July, 1, 2012");
Task TaskAug = task.clone();
Taskaug.setStartDate("Aug, 1, 2012");
Task TaskSept = task.clone();
TaskSept.setStartDate("Sept, 1, 2012");
}
</code></pre>
<p>So as you can see I created the task once a month because frequency is monthly ( I can have biweekly or monthly only) and it happened on the 1st because thats the start date and it never exceeded september because the enddate is sept 15.</p>
<p>I know I have to use Calendar and loop to do it but I just can't figure it out</p>
| java | [1] |
5,336,259 | 5,336,260 | Applying a function all values in an array | <p>$jobs is an array retrieved from a DB query. <code>print_r($jobs)</code> shows:</p>
<pre><code>Array
(
[ID] => 131
[Title] => -bla-
[Baseline] => lorem ipsum ...
[Description] => <ul><li>list 1</li><li>list 2</li></ul>
[EventID] => 1008
)
Array
(
[ID] => 132
[Title] => -bla 2-
[Baseline] => lorem ipsum lorem ipsum...
[Description] => <ul><li>list 1</li><li>list 2</li></ul>
[EventID] => 1009
)
</code></pre>
<p>etc ...</p>
<p>Id like to run utf8_encode() on all values of these arrays. I'm not sure if I should use array_map, array_walk_recursive ? The output should not alter the names of the array keys so that I don't need to change anything in my template, so</p>
<pre><code><h1><?=$j['title']?></h1>
</code></pre>
<p>should still work, albeit utf8 encoded.</p>
<p>EDIT: I'm trying the following, no luck</p>
<pre><code>function fix_chars($key, $value)
{
return utf8_encode($value);
}
array_walk_recursive($jobs, 'fix_chars');
</code></pre>
| php | [2] |
5,346,215 | 5,346,216 | Create object from string | <p>Is it possible to create a new object using a string?
For example how i convert the string "product" to <code>var p = new Product</code></p>
<p>Thanks in advance</p>
<p><strong>EDIT</strong></p>
<p>What I want to do is to have a menu with <code><a href="#home"></a><a href="#products">products</a></code> and create the corresponding object from the href each time. </p>
| javascript | [3] |
65,577 | 65,578 | How can I hide a specific <li>'s and show it when a specific <li> is clicked? | <p>What I want to happen is that I want to hide the <code><li></code>'s whose <code>parent_id</code> is equals to other <code><li></code>'s <code>group_id</code>. And show those <code><li></code>s when the <code>'<li>'</code> is clicked?</p>
<p>here is my sample <code><ul></code> and it is PHP generated.</p>
<p><img src="http://i.stack.imgur.com/JWqay.png" alt="enter image description here"></p>
<p>PHP Code:</p>
<pre><code>foreach($navs as $nav){
echo '<li parent_id="'.$nav['parent_id'].'" group_id="'.$nav['group_id'].'"><a href="#'.$nav['group_id'].'" class="scroll" title="'.$nav['nav'].'">'.$nav['nav'].'</a></li>';
}
</code></pre>
<p>sample output:
<img src="http://i.stack.imgur.com/3Lc6G.png" alt="enter image description here"></p>
| jquery | [5] |
5,209,527 | 5,209,528 | how to get MacID of mobiledevice in android? | <p>how to get MacID of mobiledevice in android?</p>
| android | [4] |
4,242,463 | 4,242,464 | Custom keyboard with Adaptxt SDK | <p>I'm working on custome keyboard with integration of openAdaptxt SDK for android .
I'm stuck at auto-correction feature , on hit of space .</p>
<p>Has anyone integrated the OpenAdaptxt SDK!</p>
<p>Thanks!</p>
| android | [4] |
3,953,779 | 3,953,780 | Changing the Default Installation Path in Windows Application | <p>I want to Change default installation path which is Program Files in windows application When Creating setup. I tried but i couldn't do that please tell me solution.</p>
| c# | [0] |
5,746,553 | 5,746,554 | Determine the device by which the image is captured | <p>I am working on a camera app where I need to determine by which device the image has been taken and according to the resolution of camera of the device I need to set different overlays on the camera view. for example if I capture image using the iphone3,iphone4,ipad2 and ipad3. I know that the resolution of the camera is different in various devices. Please let me know if it is possible.</p>
<p>Thanks </p>
| iphone | [8] |
678,319 | 678,320 | javascript with php | <p>I want to change the text of a label after an event.</p>
<p>e.g.:
<code><td><label id="labelId" for="error"></label></td></code></p>
<pre><code>if(isset($_POST['submit'])) {
// here i wanna to make label text = "something";
}
</code></pre>
<p>How can I do this?</p>
<p>Thanks in advance</p>
| php | [2] |
5,057,845 | 5,057,846 | Testing smartphone application on tablet | <p>I have created a map application for android smart phones and I want it to test on real device.I want to test it on galaxy tab as I don't have android phone to test but when I am running it its UI get destorted. Can anyone suggest how to run it on tablet.</p>
| android | [4] |
1,516,655 | 1,516,656 | Get text occurrences between newlines | <p>I have this for an example</p>
<pre><code>test¶test1¶test2¶test3
</code></pre>
<p>This should return 4</p>
<p>However</p>
<pre><code>test¶test1¶test2¶
</code></pre>
<p>should return 3 because there is not text after the 3rd newline.</p>
<p>I can do something like </p>
<pre><code>str.split("\n").length
</code></pre>
<p>This will only give me the amount of newlines. I'm not sure what to try to just return text between the newlines. Would regex work?</p>
<p>Thanks for any help</p>
| java | [1] |
374,154 | 374,155 | how inheritance replace the switch case? | <p>I m using C# Switch case how i can replace using inheritance.
case is like 1,2,3,4 so
how i can implement it.</p>
<p>for eg: </p>
<pre><code> public Blocks(int code)
{
bool[,] shp1;
switch (code)
{
case 1:
this._Width = 4;
this._Height = 1;
this._Top = 0;
this._Left = 4;
shp1 = new bool[_Width, _Height];
shp1[0, 0] = true;
shp1[1, 0] = true;
shp1[2, 0] = true;
shp1[3, 0] = true;
this.Shape = shp1;
break;
case 2:
this._Width = 2;
this._Height = 2;
this._Top = 0;
this._Left = 4;
shp1 = new bool[_Width, _Height];
shp1[0, 0] = true;
shp1[0, 1] = true;
shp1[1, 0] = true;
shp1[1, 1] = true;
this.Shape = shp1;
break;
default:
throw new ArgumentException("Invalid Block Code");
}
}
</code></pre>
| c# | [0] |
5,447,625 | 5,447,626 | Auto-close or overwrite browser tabs opened thru command line | <p>I have a shell script producing a html page. It then opens it in a webbrowser, using the simple syntax</p>
<pre><code>opera result.html
</code></pre>
<p>However, if I run this script several times, I get as many tabs/windows as runs. I tried to load another page containing a script that opens 'result.html' into a definite target-window, but this script page will not close using window.close() or self.close() [presumably because it was not opened by a javascript...], so it's the script page that is repeated...</p>
<p>Is there a way, either to have a webbrowser open a file into a target using the commandline, or to auto-close a window that was opened thru command line?</p>
| javascript | [3] |
5,215,861 | 5,215,862 | Android netbeans textchange on button click | <p>This might be simple but I have create a simple APP that change text of text view when button clicked. The apps debug properly but does not show the change.</p>
<p>What actually happen is this.</p>
<ol>
<li><p>Apps debugs OK</p></li>
<li><p>Emulator show "Waiting debugger to attach"</p></li>
<li><p>Text does not change as button clicked</p></li>
</ol>
| android | [4] |
3,110,125 | 3,110,126 | Creating a php search bar | <p>I want to put a search box so that when you type in a persons name it selects that persons details from the database.</p>
<p>This is my search box
</p>
<pre><code><form action="users.php" method="GET">
<input id="search" type="text" placeholder="Type here">
<input id="submit" type="submit" value="Search">
</form>
</body>
</html>
</code></pre>
<p>Then here is my php to return the users</p>
<pre><code><?php
$connection = mysql_connect("localhost","root","");
mysql_select_db("blog1")or die(mysql_error());
$result = mysql_query("SELECT username FROM member");
while ($row = mysql_fetch_assoc($result)) {
echo "<div id='link' onClick='addText(\"".$row['username']."\");'>" . $row['username'] . "</div>";
}
?>
</code></pre>
<p>How do get it to just return the user that i type in the search bar instead of all the users. any help would be great as i am just learning php.</p>
| php | [2] |
1,852,333 | 1,852,334 | How is the sizeof operator implemented in c++? | <p>Can someone point me the to the implementation of sizeof operator in C++ and also some description about its implementation.</p>
<p>sizeof is one of the operator that cannot be overloaded.</p>
<p>So it means we cannot change its default behavior?</p>
| c++ | [6] |
5,553,890 | 5,553,891 | How to check if there are duplicate elements in an ArrayList in Java | <p>I have an ArrayList actors. When I print this actors variable, I get an output of like this :</p>
<p>Ram, cricket, Ram, chess</p>
<p>I want to take only only one "Ram" instead of duplication.</p>
| java | [1] |
5,798,104 | 5,798,105 | Is the behavior from (other question) a bug or expected from the JVM spec? | <p>Is the behavior of the code from this question expected?</p>
<p><a href="http://stackoverflow.com/questions/3831341">http://stackoverflow.com/questions/3831341</a></p>
| java | [1] |
2,592,718 | 2,592,719 | problem with import qt in python | <p>I want to use qt with python.
"import qt" return me :"ImportError: No module named qt". I already instaled pyqt.</p>
<p>what I hve to install in order to activate "import qt"</p>
<p>Thank You </p>
| python | [7] |
1,825,458 | 1,825,459 | How do you add an iad to a tabbarcontroller properly without using IB? | <p>I am able to add an iAd Banner View to my tab bar controller with no problem. The issue comes with the rendering. The Banner View is drawn overtop of the navigation bar in my interface. </p>
<p>How can I push the navigation bar down or is their a better approach? I need to do this all programmatically without IB.</p>
| iphone | [8] |
519,433 | 519,434 | Is there any way to convert wave file to amr using ffmpeg(without using ndk) in android? | <p>I want to convert a wave file to amr in android. How to do this using ffmpeg. I dont want to use ndk. Is there some way around for it ?
Pr anything other then using ffmpeg ?
Any help would be great.
thanks.</p>
| android | [4] |
3,436,662 | 3,436,663 | Convert object back to file | <p>I want to convert an object of System.Byte[] which is actually a file, retrieved from the database, back to file and store the file in a folder. How can we convert it using ASP.Net with C# ?</p>
| asp.net | [9] |
1,386,037 | 1,386,038 | android:layout_gravity="center_horizontal" in Java code | <p>I have added a Button to a view in java code. Basically I want to add the xml</p>
<pre><code>android:layout_gravity="center_horizontal"
</code></pre>
<p>to the Button but do this in Java code, how is this done?</p>
| android | [4] |
1,343,754 | 1,343,755 | Auto logoff while closing the winform | <p>I want to make auto logoff while closing the winform without timer access. How do I do that?</p>
| c# | [0] |
1,713,132 | 1,713,133 | Load XML from documents directory - iPhone | <p>Instead of loading a XML from the URL, I would like to load it from the documents directory(which i saved when there is Internet connection) </p>
<pre><code>NSString* filename=@"magzine.xml";
NSData *data=[NSData dataWithContentsOfURL:[[NSURL alloc] initWithString:[URLlink stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];
NSString *applicationDocumentsDir =[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
NSString *storePath = [applicationDocumentsDir stringByAppendingPathComponent:filename];
[data writeToFile:storePath atomically:YES];
NSLog(@"URL: %@",url);
xmlParser = [[NSXMLParser alloc] initWithContentsOfURL:url];
//xmlParser = [[NSXMLParser alloc] initWithContentsOfFile:filename];
[xmlParser setDelegate:self];
[xmlParser parse];
</code></pre>
<p>Now i am getting the xml from url ,that is from initwithcontentsofurl,Now i want to get the saved file from documents directory when there is no internet connection.Please help me in this ,how to load the xml??
THANKS IN ADVANCE</p>
| iphone | [8] |
3,529,514 | 3,529,515 | Remove certain tags and the html between them - Jquery | <p>If I have a string that contains this.</p>
<pre><code>Hi my name is <span class="name">Joe</span>. Just wanted to say <b>Hi</b>.
</code></pre>
<p>And I want to remove certain tags including what fills it. Example with this string would be the <code><span></code> tag only. </p>
<p><strong>I would remove</strong></p>
<p><code><span class="name">Joe</span></code></p>
<p><strong>...and the finished output would be</strong></p>
<pre><code>Hi my name is . Just wanted to say <b>Hi</b>.
</code></pre>
<p>How would I do this?</p>
| jquery | [5] |
2,167,657 | 2,167,658 | Android : How to terminate activity using if block | <p>In my Android application I need to validate user entered data. So I have used if block to do that. If user entered data is invalid I want to stop running the activity further. How to do this within if block I tried to use <code>System.exit(0)</code> but it didn't work for me.
I don't know whether there is proper way to do this without using if statements please help me.</p>
<p>Eg:</p>
<pre><code> if(!uName.equals("User")){
//Here I want to terminate the activity
}
</code></pre>
<p>Thanks!</p>
| android | [4] |
2,763,855 | 2,763,856 | Browser compatibility with AJAX function | <p>I have the following AJAX function that calls a PHP file to determine if an email is present in a db.</p>
<pre><code><script language="javascript" type="text/javascript">
//Browser Support Code
function ajaxFunction(Email){
var url="index.php?EmailCheck=Yes&Email=" + Email;
var ajaxRequest; // The variable that makes Ajax possible!
try{
// Opera 8.0+, Firefox, Safari
ajaxRequest = new XMLHttpRequest();
} catch (e){
// Internet Explorer Browsers
try{
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try{
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
// Something went wrong
alert("Your browser broke!");
return false;
}
}
}
// Create a function that will receive data sent from the server
ajaxRequest.onreadystatechange = function(){
if(ajaxRequest.readyState == 4){
if(ajaxRequest.responseText == 0) {
alert("Sorry that email is not registered.");
} else {
alert("Login successful.");
window.opener.location.reload();
window.close();
}
}
}
ajaxRequest.open("GET", url, true);
ajaxRequest.send(null);
</code></pre>
<p>}</p>
<p></p>
<p>Are there going to be any browsers this won't work for? I have had some complaints from users, but I can't replicate the errors in IE, FF, or Chrome.</p>
| javascript | [3] |
2,577,455 | 2,577,456 | I'm having problems with Regex patterns | <p>I need help with a proxy scraper I am making. My application is throwing an exception for seemingly no reason.</p>
<p>My Code</p>
<pre><code>package com.ElwynDev.PastBinBot;
import java.io.IOException;
import java.util.HashSet;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class ProxyScraper {
public static void ScrapProxy(int Pages) {
final int[] searchIds = new int[] { 225957, 278235, 240804, 258000, 227364, 244555, 438084, 438085, 438086, 438087, 438088};
final String searchUrl = "http://www.proxyfire.net/forum/showthread.php?t=56861?";
final String proxyExtractingRegex = "[1-9]{2,3}.[1-9]{2,3}.[1-9]{2,3}.[1-9]{2,3}";
Pattern r = Pattern.compile(proxyExtractingRegex);
HashSet<String> proxyHashSet = new HashSet<String>();
for(int searchId : searchIds) {
Matcher m = null;
try {
m = r.matcher(ProxyHandle.get(searchUrl + searchId, null, Pages));
while(true) {
if(m.find()){
proxyHashSet.add(m.group());
}
else
break;
}
} catch (IOException e) {
e.printStackTrace();
}
}
for(String proxy : proxyHashSet) {
FileWrighter.logTo("proxy.txt", proxy + "\n");
}
}
};
</code></pre>
<pre><code>Exception in thread "main" java.lang.NullPointerException
at java.util.regex.Matcher.getTextLength(Unknown Source)
at java.util.regex.Matcher.reset(Unknown Source)
at java.util.regex.Matcher.<init>(Unknown Source)
at java.util.regex.Pattern.matcher(Unknown Source)
at com.ElwynDev.PastBinBot.ProxyScraper.ScrapProxy(ProxyScraper.java:24)
at com.ElwynDev.PastBinBot.Main.main(Main.java:17)
</code></pre>
| java | [1] |
5,332,157 | 5,332,158 | What good PHP Software to create a membership site? | <p>I going to be creating a membership site where you have to pay (PayPal) to access content and I am to lazy to code it myself, so I wanted to know what is a good PHP software that fits my needs? I was thinking Wordpress or Drupal but are there better alternatives?</p>
| php | [2] |
464,768 | 464,769 | Assigning different data types to different instances of a class? | <p>Taking the following sample:</p>
<p><img src="http://i.stack.imgur.com/2kCIX.png" alt="enter image description here"></p>
<p>I want to add a property to <code>PreferenceOption</code> called <code>DataType</code> because different instances of <code>PreferenceOption</code> could be <code>bool</code> or <code>string</code> etc. </p>
<p>Is there a way to do this? If yes, how?</p>
<p>I was thinking something like <code>public ValueType DataType { get; set; }</code>, but when creating instances of <code>PreferenceOption</code> like:</p>
<pre><code>PreferenceOption WantsHouse = new PreferenceOption () { PreferenceOption = "Want House?", Weighting = Weighting.Low, Type = bool };
</code></pre>
<p>This doesn't work, but should give a good idea of what I want to do.</p>
<p>Any suggestions?</p>
<p>EDIT (ANSWER): using the selected answer below, here's what I'm now using (apologies for blurry image!):</p>
<pre><code>public enum Weighting { One, Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten }
public class TenantPropertyPreferenceOption<T>
{
public T PreferenceOption { get; set; }
public Weighting Weighting { get; set; }
}
public class TenantPropertyPreferenceOptions
{
TenantPropertyPreferenceOption<bool> WantsHouse = new TenantPropertyPreferenceOption<bool> () { PreferenceOption = false, Weighting = Weighting.One };
// ...
}
</code></pre>
| c# | [0] |
4,357,463 | 4,357,464 | Connecting and inserting data into mysql table using php | <p>I am a PHP newbie and have been trying for sometime now to connect to MySQL database using PHP so I can insert data into a table I have created but I am unable to do this.</p>
<p>I suspect the problem is coming from my PHP <code>.ini</code> file,but that's just me.<br>
Would be grateful if anyone can help me configure my PHP <code>.ini</code> file so I can connect to MySQL and insert data into my table. Here is my PHP script in case you are wondering.<br>
Any help will be gratefully appreciated.</p>
<pre><code><?php
$host ="localhost";
$username = "username";
$password = "password";
$database = "database1";
$table ="users";
$con = mysql_connect("localhost","username","password");
if (!$con)
{
die('Could not connect:'.mysql_error());
}
mysql_select_db("database1",$con);
$mysql = "INSERT INTO $table(name,email,password)
VALUES('$_POST[name]','$_POST[email]','$_POST[password]";
if(mysql_query($mysql)) die(mysql_error());
echo"Data inserted";
mysql_close();
?>
</code></pre>
| php | [2] |
4,849,863 | 4,849,864 | How can I create an android menu item using android setting icon | <p>Can you please tell me how can I create an android menu item using android setting icon?</p>
<p>Thank you.</p>
| android | [4] |
132,356 | 132,357 | what is the difference between CONTENT_FILTER_URI and CONTENT_URI? | <p>what are the difference between these two <strong>Contacts.CONTENT_FILTER_URI</strong> and
<strong>Contacts.CONTENT_URI</strong> in android?</p>
| android | [4] |
1,052,772 | 1,052,773 | Get current URL using adb or python or perl | <p>I want to get the current url the browser has in the address bar using any of the possible ways:</p>
<ol>
<li>adb</li>
<li>python</li>
<li>perl</li>
</ol>
<p>Thanks</p>
| android | [4] |
848,585 | 848,586 | datatable compare | <p>I have a DataTable dtOld with records from database.</p>
<p>I have a DataTable dtNew with new records to be written to the database.</p>
<p>Can someone please help with the best way to send the new DataTable dtNew to the database without records that already exist in the dtOld DataTable?</p>
<p>thanks,
rodchar</p>
| c# | [0] |
3,519,819 | 3,519,820 | jquery imgareaselect plugin not working | <p>i am using the latest version for jquery that is 1.8 and the plugin seem not working in this version.</p>
<p>My whole website is jquery 1.8 compatible and this plugin is not working and since my website is live and its used for main user profile image cropping i really am stuck. </p>
<p>Here is the plugin link <a href="https://github.com/odyniec/imgareaselect" rel="nofollow">https://github.com/odyniec/imgareaselect</a>. if anyone facing same problem and has a solution for it please share it with me. </p>
| jquery | [5] |
3,224,373 | 3,224,374 | how to findout which Class/Object is calling current winForm/object in c# | <p>hey guys, i have 3 winForms named carForm,parForm and updateForm, so there's <code>updateForm.show()</code> method in both carForm n parForm, while m in updateForm i want to know which class/form has called updateForm, so that i can update the respected class db. Currently i'm setting up a <code>public</code> global <code>variable</code> to verify that which form is calling updateForm..but i was thinkin' is there's another way to do this, i guess Reflection can solve this issue, but i'm not able to solve it, here's my code</p>
<pre><code>///carForm
public class carForm:Form
{
Program.globalvariable="CAR"; //global variable
UpdateFrom updateForm=new UpdateForm();
updateForm.Show();
}
///parForm
public class parForm:Form
{
Program.globalvariable="PAR";
UpdateFrom updateForm=new UpdateForm
updateForm.Show();
}
///updateForm
public class updateForm:Form
{
if(Program.globalvariable=="CAR")
///code for update CAR db table
else if(Program.globalvariable=="PAR")
///code for update PAR db table
Type obj = GetType(); //This is what i was tryin' using Reflection but giving error
}
</code></pre>
<p>so if i get the calling Class/Objects info, i can update respected DB table,</p>
<p>can ne1 know hw to do this with Reflection,</p>
| c# | [0] |
1,123,600 | 1,123,601 | Change event is not working in this scenario | <pre><code><table>
<tr>
<td><input type='checkbox'><span>Text1</span><input type='text'></td>
</tr>
<tr>
<td><input type='checkbox'><span>Text2</span></td>
</tr>
<tr>
<td><input type='checkbox'><span>Text3</span></td>
</tr>
<tr>
<td><input type='radio'><span>None of all</span></td>
</tr>
</table>
</code></pre>
<p>Below is my jQuery code.. </p>
<pre><code>$(':checkbox').live('change',function()
{
$(':radio').prop('checked',!$(this).prop('checked'));
});
$(':radio').live('change',function()
{
$(':checkbox').prop('checked',!$(this).prop('checked'));
});
$('table :text').live('keyup', function() {
var um = $(this).closest('td').find('input');
if ($(this).val().length > 0) {
um.prop('checked', true);
}
else {
um.prop('checked', false);
}
});
</code></pre>
<p>What the above code will do is </p>
<pre><code> 1. Checkboxes and Radio button are mutually exclusive
2. On change of a textbox automatically the checkbox inside its parent will checked/unchecked.
</code></pre>
<p>But </p>
<p><b>My concern is When i first click radio button, Then if i change text in textbox the checkbox will be checked but the radio button remains unchecked..</b> Why this is happening.. Please help me on this..</p>
| jquery | [5] |
3,349,658 | 3,349,659 | JQuery selector | <pre><code>$(document).ready(function(){
$('#hideButton').click(function(){
$('#disclaimer,#clock').hide();
});
});
</code></pre>
<p>In the above code snippet, suppose I want to add both the code</p>
<ol>
<li>for show() function to show the content and </li>
<li>for hide() function to hide the content.</li>
</ol>
<p>is it possible?</p>
| jquery | [5] |
2,544,000 | 2,544,001 | Should I use "from package import utils, settings" or "from . import utils, settings" | <p>I'm developing a Python application; it has all its code in one package and runs inside this of course. The application's Python package is of no interest from the interpreter to the user, it's simply a GUI application.</p>
<p>The question is, which style is preferred when importing modules inside the application package</p>
<pre><code>from application import settings, utils
</code></pre>
<p>or</p>
<pre><code>from . import settings, utils
</code></pre>
<p>That is I can either specify the name as it is (here 'application') or I can say "current package" by using "."</p>
<p>This is a Free software package so the possibility exists that someone wants to make a fork of my application and change its name. In that case, alternative 1 is a slight nuisance. Still, I use style 1 all the time (although early code uses style 2 in some places), since style 1 looks much better.</p>
<p>Are there any arguments for my style (1) that I have missed? Or is it stupid not to go with style 2?</p>
| python | [7] |
5,649,944 | 5,649,945 | PHP Move Files With Specific Format vs Move All Files | <p>I have these files in /public_html/ directory :</p>
<pre><code>0832.php
1481.php
2853.php
3471.php
index.php
</code></pre>
<p>and I want to move all those <strong>XXXX.php</strong> (always in 4 digits format) to directory /tmp/, except index.php. how to do it with reg-ex and loop?</p>
<p>Alternatively, how about moving all files (including index.php) first to /tmp/ then later on put only index.php back to /public_html/, which one you think is less CPU consuming?</p>
<p>Last thing, I found this tutorial to move file using PHP: <a href="http://www.kavoir.com/2009/04/php-copying-renaming-and-moving-a-file.html" rel="nofollow">http://www.kavoir.com/2009/04/php-copying-renaming-and-moving-a-file.html</a> </p>
<p>But how to move ALL files in a directory?</p>
| php | [2] |
4,374,715 | 4,374,716 | Using logical operands in javascript with objects | <p>I came across the use of the logical operand <code>&&</code> with objects however would like to know whether expressions are evaluated in the manner below only when dealing with objects.</p>
<p><strong>Code Sample</strong></p>
<pre><code>var sampleObject = {
size: 10,
shoe: {
make: "nike",
model: "air jordon"
},
color: "red"
}
console.log(sampleObject.size && sampleObject.shoe.model);
</code></pre>
<p>The out of <code>console.log(sampleObject.size && sampleObject.shoe.model);</code> returns <code>air jordon</code>. My understanding is that because the first condition i.e. <code>sampleObject.size</code> evaluated to true and isn't <code>falsely</code> it returns the value contained in the object <code>sampleObbject.shoe.model</code>.</p>
| javascript | [3] |
6,008,875 | 6,008,876 | Displaying directory/file list without server-side scripting | <p>It would be best if I could do it through just JavaScript and HTML, but I'm open to other solutions as well. I have a html file in a folder with a number of subdirectories and am trying to get a list of those subdirectories as well as the files within them. This needs to be able to run without server-side scripting, so php is out (which would have been far easier).</p>
<p>I have a file system set up like...</p>
<pre><code>index.html
subdir1
file1
file2
subdir2
file3
file4
</code></pre>
<p>etc...</p>
<p>I want index.html, when it loads, to display a list of the subdirectories and the names of the files within them. Is there a method or library that I can use to do this? The files will all be stored locally.</p>
| javascript | [3] |
1,369,068 | 1,369,069 | Reading bytes from file | <p>I'm trying to write huffman decompress, I have a function which is trying to read byte by byte whole compressed file, but I have a problem it reads only around 150 firsts bytes and rest are skipped I cant understand why.</p>
<p>Here's the function:</p>
<pre><code>public static StringBuilder odczytBajtowy(string nazwa)
{
FileStream plik = null;
StringBuilder dane = new StringBuilder("");
try
{
plik = new FileStream(@nazwa, FileMode.Open, FileAccess.Read);
int w;
int n = 0;
do
{
n++;
w = plik.ReadByte();
if (w != -1)
dane.Append(StringHelp.Reverse(Convert.ToString((byte)w,2).PadLeft(8, '0')));
}
while ((w > 0));
}
catch (FileNotFoundException)
{
Console.WriteLine("Brak pliku {0}", nazwa);
}
finally
{
if (plik != null)
{
plik.Close();
}
}
return dane;
}
</code></pre>
<p>It looks like the function reads EOF before the file is really at the end. I know there is no EOF somewhere between bytes because I'm writing there only byte values.</p>
| c# | [0] |
3,587,404 | 3,587,405 | Generation of designer file failed: Exception from HRESULT: 0x80042929 | <p>What does the following error mean? </p>
<p>Geeneration of designer file failed: Exception from HRESULT: 0x80042929 </p>
<p>It started showing up in my application when building and I'm not sure what's causing it. I'm using VS.Net 2008 and .Net 3.5</p>
| asp.net | [9] |
5,171,743 | 5,171,744 | How to upload an image with two different names in input tag with PHP? And resize them | <p>To upload the image I tried the single image upload code twice but it is not properly uploading both the images. The first one is uploaded and the second one is not.
Here is the code for the Form i used:</p>
<pre><code><form action="" method="post" enctype="multipart/form-data">
<table>
<tr><td>Title</td><td><input type="text" name="title" /></td></tr>
<tr><td>Date</td><td><input type="text" name="date" /></td></tr>
<tr><td>Thumbnail</td><td><input type="file" name="thumb" /></td></tr>
<tr><td>Image</td><td><input type="file" name="image" /></td></tr>
<tr><td>Details</td><td><textarea name="details"></textarea></td></tr>
<tr><td>&nbsp;</td><td><input type="submit" name="Submit" value="Submit" /></td></tr>
</table>
</form>
</code></pre>
| php | [2] |
1,205,011 | 1,205,012 | jQuery auto detect if I need to use .html() or .val() | <p>I am writting a jquery plugin to create ajax calls designed for my app. </p>
<p>Inside this plugin, my ajax call looks like this (reduced to what the question need) :</p>
<pre><code> $.ajax({
url: route,
type: "post",
data: inputData,
success: function(response, textStatus, jqXHR) {
if (outputSelector !== undefined) {
$(outputSelector).html(response);
// or
$(outputSelector).val(response);
}
}
});
</code></pre>
<p>outputSelector is a selector, defined outside the plugin. I do not know if this selector is a <code><div></code> or an <code><input></code> or even a <code><select></code>. Is there a smart way to know if I need to use val(), or html() ?</p>
| jquery | [5] |
2,689,711 | 2,689,712 | AsyncChannel: TODO: handle sendMessage RemoteExceptionandroid.os.DeadObjectException | <p>My Game screen get locked! and logcat is thrown with full of these messages</p>
<p>AsyncChannel: TODO: handle sendMessage RemoteExceptionandroid.os.DeadObjectException</p>
<p>When does this happen? Why does this happen! I have wild guess also to make I have soundPool of as many as 186 sound effects loaded in beginning, So does that cause this issue?</p>
| android | [4] |
3,616,117 | 3,616,118 | which name is acceptable for class extends abstract class? | <p>I have three classes:</p>
<ol>
<li><code>ZookeeperAccess</code> is interface</li>
<li><code>AbstractZookeeperAccess</code> implements ZookeeperAccess</li>
<li>is a class that extends <code>AbstractZookeeperAccess</code></li>
</ol>
<p>What would a good name for the 3rd class be?</p>
<p>I use <code>ZookeeperAccessImpl</code>, but I suppose this isn't the best name, it hint only implements the <code>ZookeeperAccess</code>, but not extends <code>AbstractZookeeperAccess</code>.</p>
<p>ps: the <code>ZookeeperAccessImpl</code> is the only class extends <code>AbstractZookeeperAccess</code> now.</p>
<p>I use abstract class to implement some code for interface, and provide some code to be abstact for ZookeeperAccessImpl to extends.</p>
<p>I update the question again. Thanks</p>
| java | [1] |
1,774,204 | 1,774,205 | Using an object to replace the switch statement | <p>I found the following exemple on the jqfundamentals site. It seems to me that the else statement is unnecessary/wrong. So what am I missing ?</p>
<pre><code>var stuffToDo = {
'bar' : function() {
alert('the value was bar -- yay!');
},
'baz' : function() {
alert('boo baz :(');
},
'default' : function() {
alert('everything else is just ok');
}
};
if (stuffToDo[foo]) {
stuffToDo[foo]();
} else {
stuffToDo['default']();
}
</code></pre>
| javascript | [3] |
115,649 | 115,650 | How to calculate distance between two locations using their longitude and latitude value | <p>Here my code i used below code to calculate the distance between two location using Their latitude and longitude. it is giving wrong distance. sometimes getting right and sometimes getting irrelevant distance. we are getting lat1 and lng1 from database.
//getting lat2 and lng2 from GPS as below</p>
<p>public class MyLocationListener implements LocationListener</p>
<pre><code> {
@Override
public void onLocationChanged(Location loc)
{
lat2=loc.getLatitude();
lng2=loc.getLongitude();
String Text = "My current location is: " +"Latitud = "+ loc.getLatitude() +"Longitud = " + loc.getLongitude();
//System.out.println("Lat & Lang form Loc"+Text);
//Toast.makeText( getApplicationContext(), Text,Toast.LENGTH_SHORT).show();
}
@Override
public void onProviderDisabled(String provider)
{
}
@Override
public void onProviderEnabled(String provider)
{
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras)
{
}
//Calculating distance
double earthRadius = 3958.75;
double dLat = Math.toRadians(lat1-lat2);
double dLng = Math.toRadians(lng1-lng2);
double a = Math.sin(dLat/2) * Math.sin(dLat/2) +
Math.cos(Math.toRadians(lat2)) * Math.cos(Math.toRadians(lat1)) *
Math.sin(dLng/2) * Math.sin(dLng/2);
double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
double dist = earthRadius * c;
</code></pre>
| android | [4] |
5,690,757 | 5,690,758 | exporting a project with a library | <p>I have a project that uses the githup facebook classes. I was wondering how i export my app with the facebook class as a library? </p>
| android | [4] |
3,709,579 | 3,709,580 | create own python link | <p>So I'm in the following situation. I have a package generated with py2app. This has it's own structure and my projects sources are located in:</p>
<pre><code>/dist.app/Contents/Resources/lib/python2.7/my_project
</code></pre>
<p>Now this works fine, however I want to give the possibility that developers add their own code where they want. So going trough all those folders every time seems rather ugly. So I was thinking I could try and (if possible):</p>
<pre><code>1. Get the my_project folder at the top level, next to dist.app
2. Create only a link in the lib folder similar to what distutils `python setup.py develop` does.
</code></pre>
<p>But I'm rather stuck here. So far what I attempted was (from the unpackaged project):</p>
<p>Do a <code>python setup.py develop</code> of my project. Go to python's site-packages and copy the <code>my_project.egg-link</code> generated there into the above mentioned place. Edit it , as it's just a path to the actual project accordingly.</p>
<p>Copy the <code>my_project.egg-info</code> that is generated next to the my_project folder.</p>
<p>This however doesn't seem to work. I also tried the easiest solution I could and create a MacOS alias of the folder which doesn't work either.</p>
<p>Any suggestions?</p>
<p>Regards,
Bogdan</p>
| python | [7] |
2,539,079 | 2,539,080 | Facebook android sdk can not import into workspace in eclipse | <p>i downloaded the facebook android application example from github and imported it using the git plugin in eclipse.The issue arose when i wanted to import the android sdk to use it as a library...and got the "no projects to import" error, please how do i solve this?..thanks.</p>
| android | [4] |
5,085,451 | 5,085,452 | ListView onclick not functioning accrodingly | <p>Hi I am using list view in my list view i have veg and non-veg.so when i click on veg it should move to next activity and display the items and when i click on Non-veg it should to next activity.I have written setonclickitemlistener() for both list items but when i press veg or non-veg it is going to Non-veg activity only.Here is the code</p>
<pre><code>public class MainActivity extends Activity {
String[] items={"veg","non-veg"};
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ListView lv= (ListView)findViewById(R.id.listView1);
ArrayAdapter<Object> adapter1 = new ArrayAdapter<Object (this,android.R.layout.simple_list_item_1,items);
lv.setAdapter(adapter1);
lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> arg0, View v, int arg2,
long arg3) {
{
Toast.makeText(getBaseContext(),"YOU HAVE SELECTED VEG", 4000).show();
Intent i=new Intent(MainActivity.this,veg.class);
startActivity(i);
}
}
});
lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
Toast.makeText(getBaseContext(),"YOU HAVE SELECTED NON-VEG", 4000).show();
Intent i=new Intent(MainActivity.this,Nonveg.class);
startActivity(i);
}
});
</code></pre>
<p>}
}</p>
<p>please tell me how to identify id for veg and non veg and how to write setonclicklistener() method. </p>
| android | [4] |
5,855,267 | 5,855,268 | Any way to show an image with an Alert | <p>All,</p>
<p>I am doing an app, where after selecting 5 images a pop should appear saying its done, and having a OK button, after clicking OK it will come to its original view.</p>
<p>How can I do that, can I show an image with the alert view.</p>
<p>Please help me.</p>
<p>Many Thanks in advance for your help</p>
| iphone | [8] |
327,498 | 327,499 | How to display a customized code in C# & DevExexpress TextEditor with mask | <p>I am trying to display a code like ABC/DEF/00012 or ABC/EDF/01234 or ABC/DEF/00009</p>
<p>I use RegEx mask \w{3}/\w{3}/?????</p>
<p>The question mark is hard part that I could not figure it out.</p>
<p>Basically, I try to display the code with characters and numbers. I want to automatically add leading zeros on the number.</p>
<p>Byron</p>
| c# | [0] |
3,097,254 | 3,097,255 | Decrease cyclomatic complexity of settings verification | <p>I have a brownfield application which has a complex method. The CC is 14. The if statements verify application settings and generate the appropriate inline SQL. </p>
<p>E.G. This if statement checks the settings. settings is custom code, a DTO with several <code>bool</code> (<strong>not</strong> <code>bool?</code>) properties.</p>
<pre><code> string conditions = " AND (";
List<string> conditionStrings = new List<string>();
if (settings.AlwaysIncludeCommonResults && settings.SelectedCommonLabs.Count > 0)
{
string common = " (Table.Name in (";
for (int i = 0; i < settings.SelectedCommonLabs.Count; i++)
{
common += string.Format("'{0}'", settings.SelectedCommonLabs[i]);
if (i < settings.SelectedCommonLabs.Count - 1)
common += ", ";
}
common += ")) ";
conditionStrings.Add(common);
}
if (settings.AlwaysSelectLast24HoursResults)
{
string last24 = " (DateDiff(hh, Table.PerformedDtm, GetDate()) < 24) ";
conditionStrings.Add(last24);
}
</code></pre>
<p>I don't know what to do to simplify this bool logic. Null coalesce?...I don't know that it will make this any better. This pattern appears several more times in the same method. So I hope to reuse the answer several times to decrease overall CC and increase readability. What do you suggest?</p>
<p><strong>UPDATED</strong><br />
After deciding to rip out the first verification, added further method logic.</p>
| c# | [0] |
51,056 | 51,057 | Running process in hidden mode | <p>How do I run external process in hidden mode (no windows should be visible) in Java. I googled and found that this can be done in .NET using the following code:</p>
<pre><code>Dim ProcessProperties As New ProcessStartInfo
ProcessProperties.FileName = "notepad"
ProcessProperties.Arguments = "myTextFile.txt"
ProcessProperties.WindowStyle = ProcessWindowStyle.Hidden
Dim myProcess As Process = Process.Start(ProcessProperties)
</code></pre>
<p>Is there any similar features provided for Java?</p>
| java | [1] |
5,203,032 | 5,203,033 | Python, sort a list of dicts by an arbitrary order | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/9994317/sorting-list-of-lists-by-a-third-list-of-specified-non-sorted-order">Sorting list of lists by a third list of specified non-sorted order</a> </p>
</blockquote>
<pre><code>a = [{'id':1}, {'id':2}, {'id':3}]
b = [2,1,3]
</code></pre>
<p>What would be a good method to sort <code>dict</code> a by <code>list</code> b via the <code>id</code> property. </p>
<p>The result should look something like this</p>
<pre><code>[{'id':2}, {'id':1}, {'id':3}]
</code></pre>
| python | [7] |
3,817,153 | 3,817,154 | PHP: Pass variables to file_get_contents() | <p>Is there a way to make this possible?</p>
<pre><code>// file.php
echo $foo;
</code></pre>
<p>then in </p>
<pre><code>// test.php
$foo = 'bar';
echo file_get_contents('file.php');
</code></pre>
<p>The output of test.php should be "bar".</p>
| php | [2] |
922,589 | 922,590 | reszing div width size with jquery | <p>I have a about 200 px width size div on the right side of the website.</p>
<p>It is like facebook chat box that provide recent timeline.</p>
<p>Here is the code that I am using to resize html div</p>
<pre><code>$(document).ready(function()
{
$("#right_timeline_div").css("width", $(window).width() - 1200);
});
$(window).resize(function()
{
$("#right_timeline_div").css("width", $(window).width() - 1200);
});
</code></pre>
<p>My code only shrink certain size of div. </p>
<p>I would like to change the div width size when the browser gets smaller size.</p>
<p>Let's say if the browser is 1200px wide, then I wanna decrease the right sidebar size with jquery.</p>
<p>I tried a lot of methods from here but it didn't work.</p>
<p>Thank you for reading my question, I hope this help other viewers who have same problem like me. </p>
| jquery | [5] |
239,628 | 239,629 | Problems with Echo Nest Earworm analyzing small mp3s | <p>Alright everyone, this one is super niche:</p>
<p>I am attempting to use the earworm.py code to analyze the timbre and pitch features of very short mp3s/tracks (1 second minimum); however, the code is returning no features and an empty graph.</p>
<p>The issue seems to stem from the function get_central(analysis, member='segments'). With short tracks, '"member = getattr(analysis, member)" returns empty.</p>
<p>Why is this? Is there a quick fix I could use like changing "member='segments'" to something that is more fine-grained?</p>
<p>Is there a way to extract timbre and pitch features from such short tracks using EchoNest?</p>
<p>Thanks in advanced from the help!</p>
| python | [7] |
5,390,062 | 5,390,063 | javascript permission denied to access property | <p>I am having an issue accessing properties from a different iframe. I keep getting this permission denied to access property error. I have seen people ask if they are using file:/// several times but no one ever is (except me) so that never gets addressed.</p>
<p>I am not doing this on the web. the src for all my frames are in the same file on my hard drive. I am trying to get some properties from objects I created in other frame</p>
<pre><code>function fill_with_pairs()
{
for (var x = 0 ; x < setLength ; x++)
{
var tempSet = sets[x];
var tempNums = tempSet.wb_numbers;
if (top.num_frame.active_list.active_nums[x].checked)
{
for (var y = 0 ; y < 4 ; y++)
{
var thesePairs = tempNums[y];
var pairBase = numbersX[thesePairs];
for (var z = y+1 ; z < 5 ; z++)
{
var pairKey = tempNums[z];
pairBase[z]++;
}
}
}
}
}
</code></pre>
| javascript | [3] |
5,521,149 | 5,521,150 | CalledFromWrongThreadException:Only the original thread that created a view hierarchy can touch its views | <p>I tried to change a value of a ListView adapter using a thread, but it throws an exception that is CalledFromWrongThreadException
can anyone call a thread that changes a value of any View element?
here is my code:</p>
<pre><code>new Thread(new Runnable(){
public void run()
{
ap=(ArrayList<Application>) getBoughtApps(android_id);
adapter1 = new MyCustomAdapter(ap);
listView = ( ListView ) MainActivity.this.findViewById(R.id.listview);
changeAdapter();
}
}).start();
</code></pre>
| android | [4] |
71,450 | 71,451 | Android - How to bring back my last existing activity after call initiated? | <p>I am giving facility to call from my application and listening for call end. I want to get back user to my application and same activity with same state. </p>
<p>I have tried with Intent.FLAG_ACTIVITY_CLEAR_TOP and some flags but nothing works.</p>
<p>Presently I am checking this in my Nexus 4.1.2 phone.</p>
<p>Can anyone help me to achieve this?</p>
<p>Thanks,</p>
<p>Saravanakumar</p>
| android | [4] |
3,894,156 | 3,894,157 | What is the difference between the two OO methodologies in javascript? | <p>I've been using the below, I've seen other code using function() { } and then using the this keyword, what is the difference here, have I actually instantiated an object below?</p>
<pre><code> var MyObj = {
propertyOne: 'a',
Method: (function() {
function MyFuncOne() {}
function MyFuncTwo() {}
return {
MyFuncOne: MyFuncOne,
MyFuncTwo: MyFuncTwo
}
})()
}
</code></pre>
| javascript | [3] |
789,603 | 789,604 | jQuery wrap is forcing multiple document ready callbacks | <p>I have the following code:</p>
<pre><code>function CreateRoundbox(selector, scope) {
$(selector).wrap('<div class=\"' + scope + ' dialog\"><div class=\"bd\"><div class=\"c\"><div class=\"s\"></div></div></div></div>');
$('div.' + scope).prepend('<div class=\"hd\"><div class=\"c\"></div></div>').append('<div class=\"ft\"><div class=\"c\"></div></div>');
}
</code></pre>
<p>Whenever I use this function and the "wrap" method is called it causes the $(document).ready() method to fire for a second time on the page. Here is the call to the function (this lives in a document ready block):</p>
<pre><code>CreateRoundbox(".roundbox", "roundbox-wrapper");
</code></pre>
<p>Has anyone ran into this before? Am I using wrap wrong?</p>
<p><strong>UPDATE</strong></p>
<p>Fixed usage line, I accidentally added a dot in the scope literal</p>
| jquery | [5] |
5,526,230 | 5,526,231 | How does java get to know which implementation object of interface to return? | <p>Please be gentle while answering, I am not a java developer (or developer in General)</p>
<p>While trying xml parsing with java I came across following - </p>
<pre><code>NodeList nodelist = document.getElementsByTagName("item");
</code></pre>
<p>Herein xml dom object let me collect all objects depending on tag name I provide, but return type is an Interface called - nodelist. Since interface can not be instantiated it was a bit surprising for me.</p>
<p>Keeping break point and debugging the code I realized that I actually get object for class DeepNodeListImpl which implements NodeList interface. </p>
<p>How does this happen? How does java know to return object of "some implementation" held by my Interface "object" in the statement declared above.</p>
<p>One more thing - while reading the java <a href="http://download.oracle.com/javase/1.4.2/docs/api/org/w3c/dom/NodeList.html" rel="nofollow">api</a> I found that IIOMetadataNode implements the NodeList but my previous code snippets does not get me object of type IIOMetadataNode </p>
| java | [1] |
2,988,731 | 2,988,732 | Why are type parameters not allowed in constructors? | <p>There are type parameters for methods. Why there are no type parameters for constructors? </p>
<h2>Example</h2>
<p>I think there are several (not many) examples where it would be usefull. My current problem was following:</p>
<pre><code>internal class ClassA
{
private readonly Delegate _delegate;
public ClassA<T>(Func<T> func)
{
_delegate = func;
}
}
</code></pre>
<p>A <code>Delegate</code> is enough for my class. But to pass it as <em>method group</em> I need to define the parameter as a <code>Func<T></code>.</p>
| c# | [0] |
5,461,936 | 5,461,937 | Jquery statement that won't J | <p>Can anyone help me with my jquery statement... </p>
<p>I have a 'share' box - on submit I want to 'force' the 'share' (user, date and message) to the screen below my cl_share_hide_me class ...so that the user does not have to reload the page to see his/her share.</p>
<p>I have gotten this far but not able to go further</p>
<p>Merci!</p>
<pre><code> <span class='cl_share_hide_me'>
<br />
<textarea spellcheck='false' class='class_share_a_post' rows="3" cols="58" id='slick-show'></textarea>
<br/>
<br />
<input type='submit' value='Share' class='cl_share_button' data-share-nid= "2749" data-share-type="field_school" /><br />
<br />
</span>
var sometext = "<div class='shared_content_background'> oy voy</div>";
var placeToPutData = $(this).parent().parent().find('.cl_share_hide_me');
placeToPutData.after(sometext);
</code></pre>
| jquery | [5] |
3,920,258 | 3,920,259 | Any open source project of Android virus? | <p>I just want to research the security mechanism of the android, so I want to find some open source project of Android virus to do some test.</p>
| android | [4] |
4,402,576 | 4,402,577 | Alternative to history.go(-1) for FireFox and Safari | <p>Is there an alternative to history.go(-1) for FireFox and Safari. Any Help would be greatly appreciated. </p>
| javascript | [3] |
2,906,813 | 2,906,814 | Reset a variable via void function | <pre><code>static void Main(string[] args)
{
int test = 1;
resetTest();
Console.Write(test); // Should be 0
}
static void resetTest()
{
test = 0;
}
</code></pre>
<p>Why doesn't it work? How can I get it? (I don't wanna to use int function and return to the variable) Now I have an error message which says that the variable test is undefined on the function resetTest.</p>
| c# | [0] |
4,063,242 | 4,063,243 | dynamic load data from xml to drop down box with jquery | <p>I took over a small web application. I am learning JQuery so I like to rewrite the current java script with JQuery. Here is what I have
1. the xml file as following</p>
<pre><code><courses>
<course title="math">
<time>1:00pm</time>
<time>3:00pm</time>
</course>
<course title="physic">
<time>1:00pm</time>
<time>3:00pm</time>
</course>
</courses>
</code></pre>
<ol>
<li>I like to load to drop down box1 with the title.</li>
<li>when select the title from the box1, the drop down box2 will fill in the time that response to the title.</li>
</ol>
<p>Thanks for any tips and helps.</p>
| jquery | [5] |
2,001,000 | 2,001,001 | How to set 2d Vector by X,Y ids as you would a 2dArray? | <p>Given a 2dArray I can directly set any element by specifying the X,Y index as such:</p>
<pre><code>2dArray[row][col] = "hello";
</code></pre>
<p>How can I accomplish the same thing with a 2D Vector or 2D ArrayList? It seems like I would need to recreate the entire column vector if i want to change any element within it, and then reset that column vector into the row. </p>
<p>I'm working on a simple tilebased game, so the ability to directly get/set by X,Y index is quite handy.</p>
<p>Thoughts? Thanks for any ideas</p>
| java | [1] |
4,936,866 | 4,936,867 | Reloading nib problem | <p>I have a navigation controller hierarchy where A loads B loads C.</p>
<p>VC A loads VC B like this:</p>
<pre><code> DetailViewController* detailController = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil];
[self.navigationController pushViewController:detailController animated:YES];
[detailController release];
detailcontroller.info = self.info
</code></pre>
<p>As shown above some data is passed from VC A to VC B</p>
<p>Then VC B loads VC C similar to above. VC c loads a large file so VC B's viewDidUnload methods is called so all nib outlets are released as well as the data passed in from A</p>
<p>When the user navigates back from VC C to VC B. VC B's viewDidLoad method is called but this does not call initWithNibName as VC A created it, so I am left with VC B without the content from the nib. </p>
<p>I feel I have design flaw somewhere but not sure how this should be done. Can anyone advise?</p>
<p>Regards</p>
| iphone | [8] |
5,966,634 | 5,966,635 | function call std::vector | <p>Below is how i am calling the function Xpath.evaluate. This is not working because of the wrong function call. please help </p>
<pre><code>std::vector<std::string> album;
xpath.evaluate("*[local-name()=*album*]/text()",album);
</code></pre>
<p>the xpath.evaluate function is </p>
<pre><code>void XPath::evaluate(char const* xpath, vector<string>& result) const
throw (Error) {
result.clear();
vector<xmlNodePtr> r;
evaluate(xpath, r);
xmlBufferPtr buff = xmlBufferCreate();
for (size_t i = 0; i < r.size(); ++i) {
xmlSaveCtxtPtr ctxt = xmlSaveToBuffer(buff, "UTF-8",
XML_SAVE_NO_DECL | XML_SAVE_NO_XHTML);
xmlNodePtr clone = xmlCopyNode(r[i], 1);
xmlSaveTree(ctxt, clone);
// OMG
if (clone->doc != NULL && clone->doc != r[i]->doc) {
xmlFreeDoc(clone->doc);
}
else {
xmlFreeNode(clone);
}
xmlSaveFlush(ctxt);
result.push_back(string((char const*) buff->content, buff->use));
xmlSaveClose(ctxt);
xmlBufferEmpty(buff);
}
xmlBufferFree(buff);
}
</code></pre>
<p>how do I call this function ??</p>
| c++ | [6] |
4,016,255 | 4,016,256 | Bind events to timestamp in javascript | <p>here is my question:</p>
<p>I've a website that works only during the night (after 21:00 until 24:00)
I have a button that says "Enter", but i want that button to <code>alert()</code> a message such as <code>'The website is not available yet'</code>.</p>
<p>But to do so it must check the time so in pseudocode:</p>
<pre><code> if (time is less more than 21:00 and less than 24:00) {
return true;
} else {
alert('the website is not available yet');
e.preventDefault;
return false;
}
</code></pre>
<p>But I don't understand how I can do that in terms time difference, in <strong>any</strong> day,
any hint?</p>
<p>thank you guys!</p>
| javascript | [3] |
4,214,160 | 4,214,161 | How to set title for UIButton? | <p>How can we set the button title for a button,i know this answer its simple,we need to set the title of the button for title ,but my need is somewhat diffrent ,i had a username which dynamically changes according to login.i set this in a button click and display it in a label within that button .my code for this is</p>
<pre><code>- (void)getFacebookProfileFinished:(ASIHTTPRequest *)request
{
// Use when fetching text data
NSString *responseString = [request responseString];
NSLog(@"Got Facebook Profile: %@", responseString);
NSString *likesString;
NSMutableDictionary *responseJSON = [responseString JSONValue];
NSString *username;
NSString *firstName = [responseJSON objectForKey:@"first_name"];
NSString *lastName = [responseJSON objectForKey:@"last_name"];
if (firstName && lastName) {
username = [NSString stringWithFormat:@"%@ %@", firstName, lastName];
} else {
username = @"mysterious user";
}
[_loginButton setTitle:username forState:UIControlStateNormal];
_lblfaceusername.text = username;
[self refresh];
}
</code></pre>
<p>i need to display the user name in another button click and have to assing the title of that button to user name the code for this is</p>
<pre><code>- (void)refresh {
if (_loginState == LoginStateStartup || _loginState == LoginStateLoggedOut) {
_loginStatusLabel.text = @"Not connected to Facebook";
[_loginButton setTitle:@"Login" forState:UIControlStateNormal];
_loginButton.hidden = NO;
} else if (_loginState == LoginStateLoggingIn) {
_loginStatusLabel.text = @"Connecting to Facebook...";
_loginButton.hidden = YES;
} else if (_loginState == LoginStateLoggedIn) {
_loginStatusLabel.text = @"Connected to Facebook";
[_loginButton setTitle:@"" forState:UIControlStateNormal];
_loginButton.hidden = NO;
}
}
</code></pre>
<p>i need to set the username in the <code>[_loginButton setTitle:@"" forState:UIControlStateNormal];</code>i want <code>[_loginButton setTitle:username forState:UIControlStateNormal]</code>;</p>
| iphone | [8] |
4,717,740 | 4,717,741 | Comparing objects | <p>I am pretty new to this ... </p>
<p>I have a class it contains some string members, some double members and some array objects. </p>
<p>I create two objects of this class, is there any simplest, efficient way of comparing these objects and say their equal ? Any suggestions? </p>
<p>I know writing a compare function but will it be time consuming. </p>
| c# | [0] |
1,609,613 | 1,609,614 | how using MotionEvent when move between two button without rise a finger | <p>i try to make my button to be accessible by talkback everytime it get focused/selected,
i use this <code>public boolean onTouch(View v, MotionEvent event) {</code></p>
<pre><code>switch ( event.getAction() ) {
case MotionEvent.ACTION_DOWN:
v.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED);
break;}
</code></pre>
<p>it is work when first time i touch a button, but when i move to next button without rise my finger, the button dont have focus, and talkback cant speak it, how i can use sendaccesibilityevent to my current button?</p>
<p>i try to use ACTION_MOVE, but i still need to rise my finger so the second button can have focus
thanx, and sorry for my english</p>
| android | [4] |
3,229,919 | 3,229,920 | Convert wchar_t to char | <p>I was wondering is it safe to do so?</p>
<pre><code>wchar_t wide = /* something */;
assert(wide >= 0 && wide < 256 &&);
char myChar = static_cast<char>(wide);
</code></pre>
<p>If I am pretty sure the wide char will fall within ASCII range.</p>
| c++ | [6] |
3,556,078 | 3,556,079 | How to call PHP preprocesser | <p>I have written a web server that servers html,js,css,images etc using C. I want to develop it that it has the capability to server PHP content also.</p>
<p>In that case I think I want to pass the PHP content to PHP preprocesser dynamically. How to call the PHP preprocesser.( I am using Ubuntu)</p>
| php | [2] |
5,987,379 | 5,987,380 | jQuery addClass won't initiate | <p>I'm trying to add a class to a pre-existing element, and I am trying the simplest of code. Anyone have any idea why the two logs would return the exact same element?</p>
<pre><code>console.log($('.btn-group.archive'));
$('.btn-group.archive').addClass('open');
console.log($('.btn-group.archive'));
</code></pre>
<p>Might be worth mentioning that I'm using Twitter Bootstrap's dropdown menu, so I don't know if there is something messing with it from there.</p>
<p>They return:</p>
<pre><code><div class="btn-group archive">
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
Select
</a>
<ul class="dropdown-menu"><!-- dropdown menu links -->
<li><a href="#">Item #1</a></li>
<li><a href="#">Item #2</a></li>
</ul>
</div>
</code></pre>
<p>Where <code><div class="btn-group archive"></code> should be <code><div class="btn-group archive open"></code>.</p>
<p>The console is logging correctly, but the class won't add.</p>
| jquery | [5] |
3,798,881 | 3,798,882 | on Click with button in jQuery | <p>I have a function that is being called when a particular element is clicked</p>
<pre><code>$(".clickThis").click(function() {
}
</code></pre>
<p>I would like to add an HTML button and when it is clicked also call this function</p>
<pre><code><input type="button" value="Cancel">
</code></pre>
<p>Do I need to add a class name to it or is there a way to target it but element?</p>
<p>Can I add second trigger to call my function like this:</p>
<pre><code>$(".clickThis, button").click(function() {
</code></pre>
| jquery | [5] |
145,358 | 145,359 | Developing a Java Application with database | <p>Sorry for this trivial question, but I am new to programming and I wanted to create a Java app that can be distributed to other computers without having to install database on that computer. </p>
<p>The app is similar to an address book app where you store details about a person. Is there a way to create something like that using netbeans which does not require a database or is there any other way to go about it.. </p>
<p>I have searched for answers, but I guess I am not searching for the right keywords which I'd appreciate if someone could enlighten me with. </p>
<p>PS: I know how to create an app like that in netbeans which is connected to a database (Mysql or Postgresql) but they cannot be moved from one computer to other? Or can it be? I don't know. </p>
<p>Thanks you in advance.. </p>
| java | [1] |
5,291,375 | 5,291,376 | Timer not working properly? C# | <p>my timer isnt working properly.
Could someone tell me whats wrong?</p>
<pre><code> public void Timer()
{
DateTime targetDate = DateTime.Now;
if (DateTime.Now > targetDate)
{
int Now = DateTime.Now.Hour;
string dtNow = Now.ToString();
targetDate = DateTime.Now.AddMinutes(1);
int targetdate = targetDate.Hour;
string TD = targetdate.ToString();
if (Now == targetdate){
Vote();
}
}
}
</code></pre>
<p>It should run the vote function when the target date is equal to the time Now.</p>
<p>Thanks,
Oliver</p>
| c# | [0] |
1,658,452 | 1,658,453 | How can I send users to PayPal after some processing on the server. {PHP} | <p>I am setting up a paid subscription service and want to keep the signup form to one page. I use PayPal as my payment processor and the standard way of dealing with paypal is to create "Buttons" that POST to PayPal.</p>
<p>However, I need to process the form data before I send the user to paypal. Once I have processed the data, how would I redirect the user to paypal from the server?</p>
<p>Thanks</p>
| php | [2] |
5,452,640 | 5,452,641 | I have an image path( image is on another server). I want to get image from that server in android. please tell me | <p>I have an image path( image is on another server). I want to get image from that server in android. I have been get data from server. but I am facing problem to getting image. please tell me</p>
| android | [4] |
1,791,401 | 1,791,402 | If i have endless loop while(true) how can i use an outside flag to stop/continue the loop? | <p>what i need to do is to add a button or two with a flag that will stop/continue the loop.
How can i do it ? </p>
<pre><code>private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
while(true)
{
cpuView();
gpuView();
Thread.Sleep(1000);
}
}
</code></pre>
| c# | [0] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.